Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations MikeeOK on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

why is {0} needed in this sample code?

Status
Not open for further replies.

SurvivorTiger

Programmer
Jul 9, 2002
265
US
Hi everyone,
I'm new to C++ .NET so this question might be a little too easy..maybe...

for(i=0; i<2; i++)
{
for(int j=0; j<3; j++)
Console::Write(&quot;{0} &quot;, __box(arr[j]));

Console::WriteLine();
}

As you can see there are two for loops that are to print out different values of a 2D array names arr. What I don't understand is this part of the code &quot;{0} &quot;, ....if i eliminate that part, nothing happens and it displays the data just as it would with that section of the code.
Thanks in advance

AIM: survivertiger & Ye This Is Me
 
It's one of the overloaded Write() methods of the Console class. The first parameter in this case is a format string. For more information see the article Formatting Overview in the .NET documentation

Code:
[C#]
public static void Write(
   string format,
   object arg0
);

-pete
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top