首页 > 其他分享 >IFormattable

IFormattable

时间:2022-12-11 14:01:52浏览次数:47  
标签:return string FirstName LastName ToString IFormattable

实现IFormattable的Tostring的方法,实现为类型输出格式化字符串。

public string ToString(string format, IFormatProvider formatProvider)
{
switch (format)
{
case "EN":
return string.Format("{0} {1}", LastName, FirstName);
case "CH":
return this.ToString();
default:
return "";
}
}

public override string ToString()
{
return FirstName + " " + LastName;
}

标签:return,string,FirstName,LastName,ToString,IFormattable
From: https://www.cnblogs.com/wen-chen/p/16973621.html

相关文章