格式化字符串

2017-08-27  本文已影响0人  Lymon

格式化字符串

对字符串格式化的输出:

Console.WriteLine("两个数相加{0}+{1}={2}",4,6,10);

多重标记

Console.WriteLine("Three integers are {1},{0} and {1}",3,5);

但是标记不能引用超出替换值列表长度以外位置的值

Console.WriteLine("Two integers are {0} and {2}",3,6);  //错误

上一篇 下一篇

猜你喜欢

热点阅读