+ 1
How could I write {0} {1}... As a string in Console.WriteLine?
static void Main(string[] args) { int x = 10; Console.WriteLine("x = {0} just a string = {0}", x); //I want the second {0} to be written as string, it is possible?
6 odpowiedzi
+ 3
int x = 10;
Console.WriteLine("x = {0} just a string = {{0}}", x);
This will work.
+ 1
I want the output to be:
"x = 10 just a string = {0}"
0
I think what you are looking for is this:
Console.Write(quot;x = {x}...");
The "quot; char before enables the direct input of variables in "{}".