From the database i am getting a list of collection which has repetitive data
for eg – total length of the List is 4 which has elements like
Item[0].Id 9
Item[1].Id 10
Item[2].id 9
Item[3].id 10
i want the collection to be of length 2 having both the Id as
Item[0].Id 9, 10
Item[1].Id 9,10
Your question is a little unclear, so I’m going to take your comment that you don’t want duplicates in your item collection as the question. If this is indeed accurate then I can think of two possible solutions: one is to filter duplicates when you get the data from the database, and the other is to enforce this in your c# code.
It won’t alter the output to two integers comma separated as you’ve put in your example, but judging from your later comments this isn’t what you’re trying to do.
SQL Solution
You could use distinct if you’re using sql to retrieve the data, for example:
becomes:
C# Collection Solution
You could use the inbuilt functions of an arraylist, for example, to prevent duplicates:
I hope one of these solves your problem! Best of luck!