Abhilash J A

Abhilash J A

  • 535
  • 2.4k
  • 596.3k

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

Feb 1 2016 11:47 PM
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)