Thursday, February 18, 2010

How to find no of unique characters in a string using in build functions in c#?

static int GetUniqueCharCountWithInBuiltFunc(string inputString)
{
if (string.IsNullOrEmpty(inputString))
{
throw new NullReferenceException();
}
char[] inputArray = inputString.Replace(" ", "").ToCharArray();
return inputArray.Distinct().Count();
}

No comments:

Post a Comment