この記号を見つけました。この記号{0}
は何を意味していますか?
5 に答える
1
文字列置換マーカーです。
この例を見てみましょう。これらのシンボルの使用法が説明されています。
class Program
{
static void Main()
{
string value1 = "Dot";
string value2 = "Net";
string value3 = "Perls";
Console.WriteLine("{0}, {1}, {2}", // <-- This is called a format string.
value1, // <-- These are substitutions.
value2,
value3);
}
}
これにより、次の出力が発生します。
ドット、ネット、パール
于 2012-09-25T07:27:17.233 に答える
0
文字列のフォーマットに使用できます:
DateTime dat = new DateTime(2012, 1, 17, 9, 30, 0);
string city = "Chicago";
int temp = -16;
string output = String.Format("At {0} in {1}, the temperature was {2} degrees.",
dat, city, temp);
Console.WriteLine(output);
// The example displays the following output:
// At 1/17/2012 9:30:00 AM in Chicago, the temperature was -16 degrees.
于 2012-09-25T07:27:28.307 に答える