+ 1

Why do I get this error : Cannot apply indexing with [] to an expression of type 'char'

I have a for-loop and I want to iterate through all characters of the string (userInput) for(int i=0; i < userInput.Length;i++) // each (char ch in userInput) { ch = userInput[i]; } Now I get the following error : Cannot apply indexing with [] to an expression of type 'char' If a string is a array, I should be able to use a indexer, why do I get this error ?

2nd Oct 2017, 7:48 PM
sneeze
sneeze - avatar
2 Réponses
+ 5
so true 😂 i guess if the compiler fixed its self it could make a human error
2nd Oct 2017, 8:06 PM
D_Stark
D_Stark - avatar
+ 3
Sorry, Error does not apply to the line. I mentioned. Problem solved. Why are compilers always right but never clear.
2nd Oct 2017, 7:52 PM
sneeze
sneeze - avatar