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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Curly Braces in Write()??? 2

Status
Not open for further replies.

colep

Programmer
Jul 18, 2002
58
0
0
US
I am new to C# and I have a question regarding what the {} do within the Write & WriteLine methods... If you look at the code below, this line in particular is confusing me System.Console.Write("{0,24}", s); - what does the {0,24} do here???

Thanks in advance!!!
Nicole

class TestRegularExpressions
{
static void Main()
{
string[] sentences =
{
"cow over the moon",
"Betsy the Cow",
"cowering in the corner",
"no match here"
};

string sPattern = "cow";

foreach (string s in sentences)
{
System.Console.Write("{0,24}", s);

if (System.Text.RegularExpressions.Regex.IsMatch(s, sPattern, System.Text.RegularExpressions.RegexOptions.IgnoreCase))
{
System.Console.WriteLine(" (match for '{0}' found)", sPattern);
}
else
{
System.Console.WriteLine();
}
}
}
}
 
They're replaceable parameters that String.Format() will substitute for you. Note that the numbers inside them indicate the order of the values -- this is because some languages (French, for example) have a different word order than English, and this lets you rearrange your format string to allow for this.

English said:
Your invoice must be dated today or later.
French said:
Votre facture doit être datée aujourd'hui ou plus tard.
Chip H.


____________________________________________________________________
If you want to get the best response to a question, please read FAQ222-2244 first
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top