Hello Sir,
string AgencyIds = "";
ListobjList = "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...


Saineshwar BageriRank #115 · 19.6K reputationPosted Feb 1, 2016, 8:23 PM EST
new SelectListItem { Text="14",Value="14"},
new SelectListItem { Text="14",Value="14"},
new SelectListItem { Text="14",Value="14"},
new SelectListItem { Text="14",Value="14"},
new SelectListItem { Text="15",Value="15"},
new SelectListItem { Text="16",Value="16"},
new SelectListItem { Text="11",Value="11"},
new SelectListItem { Text="11",Value="11"},
new SelectListItem { Text="11",Value="11"},
};
var Listout = (from a in objList
select a.Value).Distinct();
foreach (var items in Listout)
{
AgencyIds = AgencyIds + items + ",";
}
Abhilash J ARank #1,243 · 1.4K reputationPosted Feb 1, 2016, 9:29 PM EST
Saineshwar BageriRank #115 · 19.6K reputationPosted Feb 1, 2016, 9:34 PM EST
Abhilash J ARank #1,243 · 1.4K reputationPosted Feb 1, 2016, 10:21 PM EST