4
Reply

How to use distinct() in integer variables using mvc c#?

Mani Kandan

Mani Kandan

Feb 1 2016 11:47 PM
302
Hello Sir,
 
string AgencyIds = "";
List<SelectListItem> objList = new List<SelectListItem>();
objList = "This "objList" variable contain stored procedure result that is list of ids";
foreach (var items in objList)
{
AgencyIds = AgencyIds + items.agencyID + ",";
}

Output of the AgencyIds is like this:- 14,14,14,14,15,16,11,11,11 like that...
 
how to get distinct 'items.agencyID' (ie, AgencyIds) with comma for each AgencyIds using c# code?
 
But I want output like this:= AgencyIds = 14,15,16,11, like that...

Answers (4)