IEnumerable to string delimited with commas?
var singleString = string.Join(",", _values.ToArray() );
Write an extension method such as
public static String AppendAll(this IEnumerable<String> collection, String seperator)
{
using (var enumerator = collection.GetEnumerator())
{
if (!enumerator.MoveNext())
{
return String.Empty;
}
var builder = new StringBuilder().Append(enumerator.Current);
while (enumerator.MoveNext())
{
builder.Append(seperator).Append(enumerator.Current);
}
return builder.ToString();
}
}
and assuming the result of your previous expression is IEnumerable<String>, call:
var _values = _tbl.AsEnumerable().Select(x => x).AppendAll(String.Empty);
String.Join(
",",
_tbl.AsEnumerable()
.Select(r => r.Field<int>("ID").ToString())
.ToArray())
Try this:
var _values = _tbl.AsEnumerable().Select(x => x);
string valueString = _values.ToList().Aggregate((a, b) => a + b);