c# - Convert string to char error message -
cannot convert string char error message. trying able write program will, example, allow user input 1800hiethc , give them digits. stuck.... or advise on do?
static void main(string[] args) { char number = ' '; int numb = 0; console.writeline("please enter telephone number..."); number = console.readline(); while (number <= 10) { if (number == 'a') { numb = 2; } } console.writeline(numb); } }
}
console.readline gives string
a string
is, among other things, collection of char
s
try this
string number = ""; int numb = 0; console.writeline("please enter telephone number..."); number = console.readline(); for(int i=0; i<number.count; i++) { if (number[i] == 'a') { //... } }
Comments
Post a Comment