I am trying to create a string function, but when I start to implement code it's yelling at me at the first line of code.
I've tried to just implement public static string IsUniqueChar(string str),
public string IsUniqueChar(string str), both of these throw an error. I know it's something small but I can't figure it out.
public static string IsUniqueChar(string str)
{
for (int i = 0; i < str.Length; i++)
{
int val = str.ElementAt(i) - 'a';
}
}
IsUniqueChar is underlined in red saying that "not all code paths return a value".
returnastring. Or change the function return type tovoid.IsUniqueCharseems like a function that needs to return abool, not astring. Second, regardless of the return type, you must make sure that the function returns an object/value of that type to get rid of this compiler error. Please note that methods that don't return anything should have avoidreturn type.