i have one list object which contains int like below:
var list = new List<int>();
var ids=getting only ids from database.for Eg:1,2,1,3,5,6,3.
Now what i want to do is after fetching ids from datatabase i want to add in to my list object and if any differnt ids is added(eg:ids:2) then i want to break from the loop.
For Ex: After adding 1 in my list now if i try to add 2 which doesnt exist in my list object then i want to break from my loop with status different element found outside the loop.
Add values in the list object till duplicate value is found means add only duplicate values in my list object and if distinct value is found which is not already in the list then break from loop.Break from the loop after adding 1 in list because 2 is different and it is not already in the list object.
This is my code:
bool status;
for (var i = 0; i < ids.Count; i++)
{
list.Add(ids);
}
//here i want status with different element found or not
Note:I just want to add only duplicates values in my list object until new id is found.