Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialmadusanka bandara
920 PointsC# questio Console.WriteLine("Daves ags is {0}"
Employee Dave = new Employee(); Dave.age = 25; Console.WriteLine("Daves ags is {0}", Dave.age);
Dave is new class instantiate by the public class "Employee", and assign a value of 25, i dont understand the code that use in side the console.writeline to display dave's age to console, if anyone can explain that that will be great.
1 Answer
Steven Parker
231,261 PointsThe first argument is the string to be printed, and within the string the sequences in braces are placeholders that will be replaced with the values supplied by the other arguments. The number inside the braces indicates which argument to use, counting from 0. So "{0}" will be replaced by the value of the first argument, which will be Dave's age in this case.
So for this example code:
Dave.age = 25;
Console.WriteLine("Dave's age is {0}", Dave.age);
The output will be: