[RESOLVED] [2.0] ForEach Question
What is wrong here:
Code:
char[] InvalidsArray = Path.GetInvalidFileNameChars();
foreach (char x in InvalidsArray)
{
if (newName.Contains(x.ToString))
{
return false;
}
}
return true;
The line ' if (newName.Contains(x.ToString))' gives me this error 'Error 1 The best overloaded method match for 'string.Contains(string)' has some invalid arguments'
x is converted to a string, right? So what am I doing wrong?
Thanks!
Re: [2.0] ForEach Question
You need the () at the end of ToString, otherwise the compiler thinks you're refering to the actual ToString method rather than the result it returns.
C# Code:
char[] InvalidsArray = Path.GetInvalidFileNameChars();
foreach (char x in InvalidsArray)
{
if (newName.Contains(x.ToString()))
{
return false;
}
}
return true;
Re: [2.0] ForEach Question
Thank you for not prefacing your answer with 'DUH!'
I don't know how I missed that.