I have a List where I would like to add an internal counter when several items have the same name.
var myList = new List<string>();
myList.Add("a");
myList.Add("b");
myList.Add("b");
myList.Add("c");
And I want the result to be
a01
b01
b02
c01
after some fancy LINQ stuff.
Any great ideas out there?
Not saying that’s nice, but it’s a (mostly) Linq solution:
The accumulation part is pretty ugly, but it does the job and all inside a Linq computation.
EDIT
If the initial list is already sorted, this expression is cleaner (but might be inefficient, you’d have to see how many items you have in your list):