+ 1
What is the {0} for in the code?
4 Answers
+ 7
it's a place-holder, you can insert one or more values(any kind of value) inside a string. Remember that the indexer start from 0 'zero'!
Example:
String name= "LoL"
int age = 21
Console.WriteLine("My name is {0} and i'm {1}", name, age)
+ 3
More useful example:
String name= "LoL";
int age = 21;
string str = string.format("My name is {0} and i'm {1}", name, age);
Then you can do with str whatever you wish...
+ 1
it 's a place holder it will hold the place for variable to display and it follow the sequence of variable specify in the out put string . Like
String firstname="Milind";
String lastname ="Gandhi";
Console.WriteLine("My name is {0}{1}",firstname,lastname);
- 6
that for set a value out of string value