There are some issues with your code. First, you do an assignment operation and not equality (single =
vs ==
)
Secondly, if you have a string and want to check if one of his characters is space, you could do:
string myString = "This is a string";
foreach (var c in myString) {
if (c == ' ') // <=== Note the space between the single quotes
... do something
}
6
solved Parsing a char inside an if c#