Advertisement
Lauda

Most popular item in collection

Jun 2nd, 2014
227
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.63 KB | None | 0 0
  1.         private string mostPopularTag()
  2.         {
  3.             List<string> listaTagova = new List<string>();
  4.             for (int i = 0; i < Zivotinje.getInstance().getZivotinjskeVrste().Count; i++)
  5.             {
  6.                 string[] tokens = Zivotinje.getInstance().getZivotinjskeVrste()[i].ZTag.Split(new string[] { ", " }, StringSplitOptions.None);
  7.                 listaTagova.AddRange(tokens);
  8.             }
  9.  
  10.             var most = listaTagova.GroupBy(i => i).OrderByDescending(grp => grp.Count()).Select(grp => grp.Key).First();
  11.           //  MessageBox.Show(most.ToString());
  12.  
  13.             return most.ToString();
  14.         }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement