[英]Non-generic IEnumerable to string
There are a lot of questions/answers about conversion from generic IEnumerable to a string. 关于从通用 IEnumerable到字符串的转换有很多问题/答案。
But I need a conversion from a non-generic IEnumerable to a string . 但我需要从非通用的 IEnumerable转换为字符串 。 The result string should be in form of
结果字符串应为
element1.ToString() + ", " + element2.ToString() + ", " + element3.ToString() + ...
Is there a shorter way than using StringBuilder and looping through the elements by MoveNext() ? 是否有比使用StringBuilder更短的方式并通过MoveNext()循环遍历元素?
您仍然可以使用LINQ:
String.Join(", ", thingy.Cast<object>());
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.