日期:2014-05-17 浏览次数:21196 次
/// <summary>
/// 把一个字符串列表用特殊的标记串接成一个新字符串
/// </summary>
/// <param name="textList">要输出的字符串数组</param>
/// <param name="connector">要串联的间隔符</param>
/// <param name="isIgnoreEmptyEntries">是否忽略Empty或Null项</param>
/// <returns></returns>
public static string ToString(this IEnumerable<string> textList, string connector = "<br/>", bool isIgnoreEmptyEntries = false)
{
StringBuilder sb = new StringBuilder();
foreach (var item in textList)
{
if (isIgnoreEmptyEntries && string.IsNullOrWhiteSpace(item))
{
continue;
}
if (sb.Length > 0)
{
sb.Append(connector);
}
sb.Append(item);
}
return sb.ToString();
}
List<string> list = new List<string>() { "a", "b", "c" };
this.lbl_AppGroup.Text = list.ToString();