Robert,
[quoted text, click to view] > Okay, so if I'm understanding you guys correctly {3} is the old way
> and + is the new way?
No. Consider:
int temp = 100;
int wind = 10;
int rainfall = 0;
string format1 = "Temperature: {0} Wind: {1} Rainfall: {2}";
string format2 = "Wind: {1} Rainfall: {2} Temperature: {0}";
string format3 = "Rainfall: {2} Wind: {1} Temperature: {0} ";
Console.WriteLine(format1, temp, wind, rainfall);
Console.WriteLine(format2, temp, wind, rainfall);
Console.WriteLine(format3, temp, wind, rainfall);
Notice that I use one of three format strings, but the other parameters are
given in a fixed order. Notice that in each format string that I have the
same placeholders {0}, {1}, {2}, but they show up in a different sequence.
If you run the above your output would be:
Temperature: 100 Wind: 10 Rainfall: 0
Wind: 10 Rainfall: 0 Temperature: 100
Rainfall: 0 Wind: 10 Temperature: 100
Now I used English on all three, however consider what happens when format1
is English, format2 = French, format3 = German. & the format string itself
is read from a Resource file which are organized by language.
[quoted text, click to view] > And I probably shouldn't use {0} anymore? or does it depend...
No you should use {0}! especially if you want to internationalize your app.
[quoted text, click to view] > because I thought I remember that if you type something like this
> Console.WriteLine("The current road conditions are {0}", (int) icey);
int icey = 100;
Console.WriteLine("The current road conditions are {0}", (int) icey);
Prints: "The current road conditions are 100"
Hope this helps
Jay
[quoted text, click to view] "Robert Blackwell" <Robbie@dontwowcentralspam.com> wrote in message
news:%23RBo9ZVeDHA.2304@TK2MSFTNGP10.phx.gbl...
> This makes better sense after you explained it since I'm slightly familiar
> with PHP and it uses a . instead of a +
>
> echo "Welcome ".$currentUser."!";
>
> so, depending where the variable is being added, before preiod goes after,
> between, on both sides, and after period goes before.
>
>
> Okay, so if I'm understanding you guys correctly {3} is the old way
>
> and + is the new way?
>
> And I probably shouldn't use {0} anymore? or does it depend...
>
> because I thought I remember that if you type something like this
> Console.WriteLine("The current road conditions are {0}", (int) icey);
>
> and that would display icey intead of the variable assigned to icey?
>
> I'm not possitive if I typed that correctly, I'd have to go back to my
other
> book to make sure.
>
>