+ 23

What's the meaning of {0} ?

30th Jul 2016, 6:38 AM
DanielZillatorChannel
DanielZillatorChannel - avatar
14 Answers
+ 39
its like a varuable statement that will change depend on what the list is one example: int age = 18; Console.WriteLine("Your age is{0}", age); the output is Your age is 18 see the "age" word beside {0}? it means the {0} is the variable that outdepend on the indentifer so the age is inputed to {0} example int age = 18; string name = Console.ReadLine(); Console.WriteLine("Age is {0} and your name is {1}", age, name); now theres 2 {} and 2 identifer beside {1}, its "age" and "name", the "age" its inputed to {0} because its in the front, and the "name" is inputed to {1} because its in backward of the "age"
30th Jul 2016, 9:45 AM
Elvin Tech
Elvin Tech - avatar
+ 13
The name given to {0} is called "placeholder". It tells the argument of ReadLine() in this case that there is a variable whose value is going to get inserted or placed at the position of {0} in the string. The "0" means its the first variable, so the second will be {1} and so on.
31st Jul 2016, 12:41 AM
Pablo Hernandez
+ 4
{0} is a placeholder for your variable. eg: a = 1 console.writeline("{0}",a); if there is another variable the '0' increaments to '1' that is {1}. eg: a=1 & b=2 console.writeline("a is {0} ] and b is {1}", a, b);
23rd Dec 2016, 7:21 AM
Andrew Ndhlangisa
0
it's a placeholder...
22nd Dec 2016, 11:48 AM
keith roby
keith roby - avatar
0
it's a place holder mainly used for formatting.
22nd Dec 2016, 12:48 PM
Asish Mohapatra
Asish Mohapatra - avatar
0
in c# 6 you can use now string interpolation where if you have a name variable you can format something like below. using static System.Console; /* Static name space declaration to use the static method of the class directly with no class name*/ var name= "Asish"; var lastName="Mohapatra"; var data=
quot;hi ! my name is {name} and my last name is {lastName}; Writeline(data); Output hi ! my name is Asish and my last name is Mohapatra. Explanation Here we have used $ to indicate that we are using string interpolation. instead of using {0} or {1} now we are using exact variable. This is available only on C# 6 !!!!!
25th Jan 2017, 1:08 AM
Asish Mohapatra
Asish Mohapatra - avatar
0
{0} placeholder for your variable
11th Feb 2017, 11:53 AM
manu
- 1
Thanks
30th Jul 2016, 9:53 AM
DanielZillatorChannel
DanielZillatorChannel - avatar
- 1
its a hole between event horizon.
21st Dec 2016, 4:17 PM
M.I.Rayhan
M.I.Rayhan - avatar
- 1
null maybe.
24th Dec 2016, 7:53 AM
ShIvam Rawat
ShIvam Rawat - avatar
- 3
input function
23rd Dec 2016, 7:38 AM
meena.s
- 4
so its not necessary to include????
22nd Dec 2016, 7:17 AM
Mohan Chandra
Mohan Chandra - avatar
- 4
Placeholder 0
22nd Dec 2016, 3:09 PM
Dunga
Dunga  - avatar
- 4
input
23rd Dec 2016, 7:33 AM
meena.s