I'm learning c# and i've seen it {0},{1}
[...]. What it means?
Example:
Console.WriteLine("\nContains(\"1734\"): {0}",
parts.Contains(new Part {PartId=1734, PartName="" }));
I'm learning c# and i've seen it {0},{1}
[...]. What it means?
Example:
Console.WriteLine("\nContains(\"1734\"): {0}",
parts.Contains(new Part {PartId=1734, PartName="" }));
Placeholders for argument substitution during string format. Those will be replaced with actual values. In your case x
, y
, z
, result
. You can write:
Console.WriteLine("The average of {0}, {1} and {2} is: {3}", x, y, z, result);
as
Console.WriteLine(string.Format("The average of {0}, {1} and {2} is: {3}", x, y, z, result));
Which can be optimized using latest C# syntax (feature is called string interpolation):
Console.WriteLine($"The average of {x}, {y} and {z} is: {result}");
This last line is pretty clear for what it does.
You can optionally specify output style (number of significant digits, leading zeroes etc.) - see this for syntax and examples: https://msdn.microsoft.com/en-us/library/system.string.format(v=vs.110).aspx.
If you run it you will see the result. It will put x, the parameter at 0 index in the {0} It will put y in the {1} and so on Best to play around. Although most people use the $" the value of X is {x}";