I am using below code to append diffrent Product with comma but the problem is if i get the same name again then how to show only distinct value.
Eg-> AA,BB,CC,DD - This is correct
but in some scenarios i get value as AA,AA,AA,AA then i want to show as 'AA' only.
ProductName = String.Join(",", g.Select(s => s.ProductName))
You can use the
Distinct() extension method on the result of your
Select method call.
String.Join(",", g.Select(s => s.ProductName).Distinct())