C#中Append()的用法
1、string &append(const string &s,int pos,int n);//把字符串s中从pos开始的n个字符连接到当前字符串的结尾
举例:
class Person
{
private string firstStr;
private string middleStr;
private string lastStr;
public Person(string fs, string ms, string ls)
{
firstStr = fs;
middleStr = ms;
lastStr = ls;
}
public void disFullName()
{
StringBuilder FullStr =new StringBuilder();
FullStr.Append(firstStr,0,1);
FullStr.Append(middleStr,1,2);
FullStr.Append(lastStr);
Console.WriteLine(FullStr);
}
}
static void Main(string[] args)
{
Person people = new Person("我", "真的爱你", "啊啊啊?");
people.disFullName();
Console.ReadKey();
}
输出的结果为:
1、string &append(const string &s,int pos,int n);//把字符串s中从pos开始的n个字符连接到当前字符串的结尾
举例:
class Person
{
private string firstStr;
private string middleStr;
private string lastStr;
public Person(string fs, string ms, string ls)
{
firstStr = fs;
middleStr = ms;
lastStr = ls;
}
public void disFullName()
{
StringBuilder FullStr =new StringBuilder();
FullStr.Append(firstStr,0,1);
FullStr.Append(middleStr,1,2);
FullStr.Append(lastStr);
Console.WriteLine(FullStr);
}
}
static void Main(string[] args)
{
Person people = new Person("我", "真的爱你", "啊啊啊?");
people.disFullName();
Console.ReadKey();
}
输出的结果为: