0

Why we are using {0}???

5th Apr 2017, 11:30 PM
Khadija Afzaal
Khadija Afzaal - avatar
3 Answers
+ 7
{0} is refer to first index number {1} is refer to second index number and so on. example: int x = 5; double y = 6.8; int z = 7; Console.WriteLine("numbers are {0} and {2}", x,y,z) ; /*the output is : numbers are 5 and 7*/
6th Apr 2017, 5:12 AM
Agus Mei
Agus Mei - avatar
+ 4
This is for printing a formatted string. For exmple: String.Format(“This {0} an example.“, “is“); //output This is an example. You can store variables in there too like: string text = “is“; Console.WriteLine(“This {0} an example.“, text);
6th Apr 2017, 12:44 AM
Max_N
Max_N - avatar
+ 1
Got it thanks a lot :)
6th Apr 2017, 5:25 AM
Khadija Afzaal
Khadija Afzaal - avatar