C#中的String.Format方法

定义
String.Format是将指定的String类型的数据中的每个格式项替换为相应对象的值的文本等效项.
(1)
string p1="xiaomeng";
string p2="xiaobei";
Response.Write(String.Format("Hello {0},I'm {1}",p1,p1));
(2)
Response.Write(String.Format("Hello {0},I'm {1}","xiaomeng","xiaobei"));
这两种的效果是一样的.但是将后面的两项值分别替换第一项的{0}和{1}.
输出结果:Hello xiaomeng,I'm xiaobei.

原文地址:https://www.cnblogs.com/liubeimeng/p/3829742.html