0

Why is x and y given 0 and 1 respectively

using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace SoloLearn { class Program { static void Main(string[] args) { int x = 10; double y = 20; Console.WriteLine("x = {0}; y = {1}", x, y); } } }

5th Jun 2018, 3:06 PM
bhirkoff
bhirkoff - avatar
1 Odpowiedź
+ 8
The overload specification accepts the first argument as the format string ("x = {0}; y = {1}"). Whatever comes after the format string are treated as indexed arguments which are referred to by their index, because <x> comes after the format string it is referred to as the first indexed argument (index: 0), <y> that comes after <x> is referred to as the second indexed argument (index: 1). If there were more arguments following the format string, each successive ones are referred to by their index, remember, indexing here uses zero based number. Hth, cmiiw
5th Jun 2018, 3:37 PM
Ipang