我必须使用单个字符串将应用程序的地址格式化为如下所示的格式。
1421 COUNTRY CLUB RD
PO BOX 953
CAMDEN
USA
但是我的表中每个字段都有不同的列。
我必须将它们格式化为单个字符串并像这样显示。
Address1
Address2
Address3
City
ZIPCode
County
State
Country
到目前为止,我要做的是在模型中将它们格式化为字符串
public string DisplayShippingAddress
{
get { return string.Format("{0} {1} {2} {3} {4} {5} {6} {7}", this.Address1, this.Address2, this.Address3,this.City,this.ZIPCode, this.County,this.State,this.Country); }
}
但是我得到了一个单行字符串,我需要像上面一样格式化它
要在行之间分割字符串,只需使用换行符:'\ n'
get { return string.Format("{0}\n{1}\n{2}\n{3}\n{4}\n{5}\n{6}\n{7}", this.Address1, this.Address2, this.Address3,this.City,this.ZIPCode, this.County,this.State,this.Country); }
默认情况下,大多数控件不是多行的,因此请确保在用于输出此控件的任何控件中将其打开。
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句