+ 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?

16th Dec 2019, 7:50 AM
Cristian Daraban
Cristian Daraban - avatar
3 Answers
+ 3
int x = 10; Console.WriteLine("x = {0} just a string = {{0}}", x); This will work.
16th Dec 2019, 9:20 AM
blACk sh4d0w
blACk sh4d0w - avatar
+ 1
I want the output to be: "x = 10 just a string = {0}"
16th Dec 2019, 9:01 AM
Cristian Daraban
Cristian Daraban - avatar
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 "{}".
18th Dec 2019, 1:34 PM
CapCode