Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>Well, you're certainly right that the code's not particularly clear :)</p> <p>I don't really follow the main loop of your code, but here's a simpler starting point. Note that it won't group 0-9 properly (it only deals with 0 at the moment): I'm not sure the best way to approach that, to be honest. You might want to put that off until you get some entries which don't match any of the normal letters...</p> <pre><code>using System; using System.Linq; class Test { static void Main(string[] args) { ShowGroups(); } private static readonly char[] Letters = "ABCDEFGHIJKLMNOPQRSTUVWXYZÅÄÖ0".ToCharArray(); // This is taking the place of EntityBase.db.Services // for the purposes of the test program public static string[] Services = { "Blogger", "Delicious", "Digg", "Ebay", "Facebook", "Feed", "Flickr", "Friendfeed", "Friendster", "Furl", "Google", "Gosupermodel", "Lastfm", "Linkedin", "Livejournal", "Magnolia", "Mixx", "Myspace", "NetOnBuy", "Netvibes", "Newsvine", "Picasa", "Pownce", "Reddit", "Stumbleupon", "Technorati", "Twitter", "Vimeo", "Webshots", "Wordpress" }; public static void ShowGroups() { var groupedByLetter = from letter in Letters join service in Services on letter equals service[0] into grouped select new { Letter = letter, Services = grouped }; // Demo of how to access the groups foreach (var entry in groupedByLetter) { Console.WriteLine("=== {0} ===", entry.Letter); foreach (var service in entry.Services) { Console.WriteLine (" {0}", service); } Console.WriteLine(); } } } </code></pre> <p>I don't know how you intend to split the results into 5 equal columns though...</p>
 

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