See the documentation of this method.
There are several overloads to call you, each handles the information in a different way. Most are for basic types of language and as can be seen only accepts one argument.
To overload that accepts multiple arguments cannot be used directly, the first argument must be a string with the formatting that will be applied to the content and then the arguments that should be printed using this formatting. This is what you should use.
There is a another that accepts more than one argument. How this overload accepts int
as second and third argument, it is the one that has come closer to what it seems to need, so the compiler mistakenly choose this.
This is called betterness.
In these cases the ideal is to use interpolation of string, avoids a lot of problems and becomes more readable (some disagree). So:
using static System.Console;
public class Program {
public static void Main() {
WriteLine("Digite um número com três dígitos");
if (int.TryParse(ReadLine(), out var numero) && numero < 10000) WriteLine($"{numero / 100} {(numero % 100) / 10} {(numero % 100) % 10}");
}
}
Behold working in the ideone. And in the .NET Fiddle. Also put on the Github for future reference.
I fixed other code issues and made it more efficient and simple.
Put the same code in text and the error description, it is easier to help.
– Maniero
Want to print the three values on the console? Use this method Verload
Console.WriteLine(String)
.– vinibrsl