Answers for "remove duplicate characters in a string C#"

C#
0

remove duplicate characters in a string C#

public static string RemoveDuplicates(string input)
{
    return new string(input.ToCharArray().Distinct().ToArray());
}
Posted by: Guest on February-25-2021
0

remove duplicate characters in a string C#

string removedupes(string s)
{
    string newString = string.Empty;
    List<char> found = new List<char>();
    foreach(char c in s)
    {
       if(found.Contains(c))
          continue;

       newString+=c.ToString();
       found.Add(c);
    }
    return newString;
}
Posted by: Guest on February-25-2021

Code answers related to "remove duplicate characters in a string C#"

C# Answers by Framework

Browse Popular Code Answers by Language