I want to remove duplicate string also sort the string array in C# I am reading text file which contains data like Blue, Green, Red, Green, Yellow so I am reading data using File.ReadAllLines() which return an array of string now how to sort and remove duplicate.
private string[] sortArray(string[] str)
{
    int cnt = str.Length - 1;
    for (int i = 0; i < cnt; i++)
    {
        for (int j = cnt; j > i; j--)
        {
            if (((IComparable)str[j - 1]).CompareTo(str[j]) > 0)
            {
                var temp = str[j - 1];
                str[j - 1] = str[j];
                str[j] = temp;
            }
        }
    }
    return str;
}
using this above code I can sort the array but how to remove the duplicate string thanks in advance :)
 
     
     
    