Note that there are some explanatory texts on larger screens.

plurals
  1. POWhat am i doing wrong with my C# looping
    primarykey
    data
    text
    <p>Ok so i have 2 lists </p> <pre><code>List&lt;string&gt; playlists List&lt;string&gt; sync </code></pre> <p>and the lets say the content of playlists is three strings</p> <pre><code>{"more and you", "and us", "more"} </code></pre> <p>and the content of sync is this </p> <pre><code>{"more and you-20120312", "more and you-20120314", "more and you-20120313", "and us-20120313", "and us-20120314", "more-20120314", "more-20120313", "more-20120312"} </code></pre> <p>Basically what i want to do is loop through all the loop through the playlists and find the associated syncs and print them out and they need to be 3 otherwise i want to color them differently..So here is my code so far</p> <pre><code> StringBuilder sb = new StringBuilder(); sb.Append("&lt;h2&gt;Playlist Information&lt;/h2&gt;"); foreach (string play in playlists) { int counter = 0; foreach (string s in sync) { if (s.StartsWith(play)) { sb.Append("&lt;p class=\"good\"&gt;" + s + "&lt;/p&gt;"); counter++; } } } </code></pre> <p>So i want the final html to look like this</p> <pre><code>&lt;h2&gt;Playlist Information&lt;/h2&gt; &lt;p class=\"good\"&gt;more and you-20120312&lt;/p&gt; &lt;p class=\"good\"&gt;more and you-20120313&lt;/p&gt; &lt;p class=\"good\"&gt;more and you-20120314&lt;/p&gt; &lt;p class=\"bad\"&gt;and us-20120313&lt;/p&gt; &lt;p class=\"bad\"&gt;and us-20120314&lt;/p&gt; &lt;p class=\"good\"&gt;more-20120312&lt;/p&gt; &lt;p class=\"good\"&gt;more-20120313&lt;/p&gt; &lt;p class=\"good\"&gt;more-20120314&lt;/p&gt; </code></pre> <p>the bad for the items that dont meet at least 3...any ideas on how to achieve this with my code</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload