Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- int[] arr = new int[5] {1,2,3,4,5};
- string => "1,2,3,4,5"
- var result = string.Join(",", arr);
- public static string Join<T>(string separator, IEnumerable<T> values);
- string.Join(",", arr)
- string.Join(",", Array.ConvertAll(arr, x => x.ToString()))
- public static string ToDelimitedString<T>(this IEnumerable<T> lst, string separator = ", ")
- {
- return lst.ToDelimitedString(p => p, separator);
- }
- public static string ToDelimitedString<S, T>(this IEnumerable<S> lst, Func<S, T> selector,
- string separator = ", ")
- {
- return string.Join(separator, lst.Select(selector));
- }
- new int[] { 1, 2, 3, 4, 5 }.ToDelimitedString();
- int[] arr = new int[5] {1,2,3,4,5};
- String arrTostr = arr.Select(a => a.ToString()).Aggregate((i, j) => i + "," + j);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement