How to convert enum to long one string with LINQ

I am wondering if there is a simple and clean way (one line) to convert a long (IEnumerable) enum to one line (string) with LINQ?

thanks

0


a source to share


3 answers


If you want long (whole numbers?) Separated by commas, try:



string str = string.Join(", ", myLongs.Select(l => l.ToString()).ToArray());

      

+5


a source


Sounds like an assignment for aggregate / fold:

var longs = new long[] {3, 2, 1, 0};
var str = longs.Aggregate("", (s, l) => s + l);
// str = "3210"

      



Although I'm not really sure what the question is.

+2


a source


String.Join(yourIEnumerable, yourDelimiter)

      

0


a source







All Articles