Search code examples
c#stringintconsole.writeline

Exception with int to string convert in WriteLine


Picture

Exception on english: "Argument 1: cant convert "int" into "string".

But in my parametrs and arguments I used only "int" type.

How can I typed my parameters (X and Y) used WriteLine method?


Solution

  • Add an explicit .ToString, e.g.

    Console.WriteLine(3.ToString());
    

    Or use string.format:

    Console.WriteLine(String.Format("{0}, {1}", a, b));
    

    (Amongst others).