0
Converting string to int
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace Code_Coach_Challenge { class Program { static void Main(string[] args) { //your code goes here int a = Console.ReadLine(); int b = 30; int x = a % b; Convert.ToInt32(Console.WriteLine(x)); } } } I don't understand what is wrong with this code. Did I convert to int in the wrong spot?
2 Respuestas
+ 4
Skipps
WriteLine used to print values and ReadLine() use to get data.
Console.ReadLine() returns String value so to get int value you have to convert using Convert.ToInt32();
So here
int n = Convert.ToInt32(Console.ReadLine());
----To print n ----
Console.WriteLine(n);
+ 1
Console.writeline does not create string. It writes argument to standard output stream.