Sheeraz Ahmed

Sheeraz Ahmed

  • NA
  • 1
  • 1.7k

Data Type Conversion

Jun 24 2007 2:56 AM
Hey can any one tell me please... i input 4 digits in the input buffer... (1234) and read them as string myString = Console.ReadLine(); then i wasnt to split those number into individual digits. int=input=0;char c; for (int i = 0; i < myString.Length; i++) { c = myString[i]; input = Convert.ToInt32(c); Console.WriteLine(input); } after the compilation of the program and user input i get this output 49 50 51 52 where as i think it should be something like 1 2 3 4 so my problem is that...Convert.ToInt32(c); is not converting...and i am not getting error as well. and when i change this type conversion line of code to input = Int32.Parse(c); then i get the following error CODE Error 1 The best overloaded method match for 'int.Parse(string)' has some invalid arguments D:\My .NET Work\C #\Console\Dietel C Sharp\Chapter 4\Exercise 4.15\Exercise 4.15\Program.cs 30 25 Exercise 4.15 Error 2 Argument '1': cannot convert from 'char' to 'string' D:\My .NET Work\C #\Console\Dietel C Sharp\Chapter 4\Exercise 4.15\Exercise 4.15\Program.cs 30 37 Exercise 4.15 please help me solve this tiny problem...thank you. RentedLips § Rented Lips § ---------------- Begning To Learn ----------------

Answers (1)