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 chars

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

Popular posts from this blog

java - Run a .jar on Heroku -

java - Jtable duplicate Rows -

validation - How to pass paramaters like unix into windows batch file -