I have some code as below:
char[] separator = { ',' };
String[] idList = m_idsFromRequest.Split(separator); //m_idsFromRequest="1,2....";
List<string> distinctIdList = idList.Distinct().ToList();
m_distinctIdList = distinctIdList.ToArray();
m_idsFromRequest = string.Join(" ", distinctIdList);
currently m_idsFromRequest = ["1","2".........."] is as such. I want to make it ["0|1","0|2".........."] like append "0|" in each element . I wanted to know id I could do it without the foreach loop.
m_idsFromRequest = string.Join(" ", m_idsFromRequest.Split(separator).Distinct());and you'll avoid creating the unneeded intermediate list and array.["1","1"]would not change as the distinct is being applied to values of["1"and'"1"]1,2,3and not a string like["1","2","3"]and would not work with the later values so the exact format of the initial string is important here.