+ 3
What is the problem here? Convert.ToString
What is the problem in this C# code ? Please send the correct code. static void Main (string [] args) { int num; num = Convert.ToString (Console.ReadLine ()); Console.WriteLine (num);
4 Answers
+ 4
The problem is that num is of type integer, but ReadLine() returns a string, converting it to string wont change anything.
Since integer and string are incompatible, you need to cast to Int (Convert.ToInt32) in order to make it work.
+ 2
Help ?
+ 2
Thanks for Naitomea and sneeze
+ 1
What are you trying to do ? (I can guess, but do think for you self)
There is a "int num", that is a integer
Convert.ToString, what is the result of convert.TOstring -> a string
A string cannot be assigned to a integer, That is the problem here.