C# - Check DataTable form same field -


I would like to check the same field in datat, and I want to set a number for each line starting from zero If the same area is found, number + 1

original table

  name ========== John John Tommy Tommy Andy < / Code> 

How to do the setup number:

  names | Number ================= John | 0 John | 1 John | 2 Tommy 0 Tommy | 1 Andy 0  

Any ideas for this? Thanks for your help.

Try it out:

  var rank = Datatable1.GroupBy (x = & Gt; x.Name). Select (g = & gt; new {g, count = g.Count ()}). Selection is too many (t = gtg; tgSelect (b = & gt; b) zip (enumerate range (1, tc), (j, i) => New {j.Name, rn = i })); Foreign exchange (var i in rank) {Console.WriteLine ("{0} {1}", i.Name, i.rn); }  

Output:

  John | 1 John | John 2 3 Tommy 1 Tommy 2 Andy 1  

Comments

Popular posts from this blog

ios - How do I use CFArrayRef in Swift? -

eclipse plugin - Run java code error: Workspace is closed -

c - Error on building source code in VC 6 -