日期:2014-05-17 浏览次数:20926 次
public static string ContactText<T>(this IEnumerable<T> en, string name, string separator)
{
string result = string.Empty;
if (en is Array)
{
result = ContactEnumerable(en, null, separator);
}
else
{
result = ContactEnumerable(en, name, separator);
}
if (result.Contains(separator))
result = result.Substring(separator.Length);
return result;
}
public static string ContactEnumerable<T>(IEnumerable<T> en, string name, string separator)
{
System.Reflection.PropertyInfo pi = null;
StringBuilder sb = new StringBuilder();
if (name == null)
{
foreach (object o in en)
sb.Append(string.Concat(separator, o));
}