|
-
Oct 8th, 2007, 04:12 PM
#1
Thread Starter
Hyperactive Member
[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!
-
Oct 8th, 2007, 04:38 PM
#2
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;
-
Oct 8th, 2007, 05:16 PM
#3
Thread Starter
Hyperactive Member
Re: [2.0] ForEach Question
Thank you for not prefacing your answer with 'DUH!'
I don't know how I missed that.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|