Distinct value


#1

Hi All I am having trouble while passing the distinct value to web type into.
I got 9 distinct values and I have to type one value in web field. when I am passing the value its typing all values.
How To do that? if I want to type one value.


Cannot add System.Double to System.String
Get the distinct value and type it into web
#2

@Chirag1991,Can you elaborate? (9 values are stored in which variable ) and can you share the input values?


#3

hi @Chirag1991

Assign the 9 values in a list

i.e List Employee= new List();

Assign a string variable and give statement
Employee.Select(x => x.Field).Distinct()

Call this variable in type into

Thanks
Ashwin S


#4

Hi @AshwinS2,

This code will not support

Try below code.
List<int> distinct = list.Distinct().ToList()

// List with duplicate elements.
List list = new List();
list.Add(1);
list.Add(2);
list.Add(3);
list.Add(3);
list.Add(4);
list.Add(4);
list.Add(4);

    foreach (int value in list)
    {
        Console.WriteLine("Before: {0}", value);
    }

    // Get distinct elements and convert into a list again.
    List<int> distinct = list.Distinct().ToList();

    foreach (int value in distinct)
    {
        Console.WriteLine("After: {0}", value);
    }

Refer this link
https://www.dotnetperls.com/remove-duplicates-list

Regards,
Arivu