从IEnumerable创建逗号分隔的列表

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了从IEnumerable创建逗号分隔的列表相关的知识,希望对你有一定的参考价值。

  1. string result = string.Empty;
  2.  
  3. List<int> listOfInts = new List<int>();
  4. foreach (int number in listOfInts)
  5. {
  6. if (number == listOfInts.Last())
  7. {
  8. result += number;
  9. }
  10. else
  11. {
  12. result += string.format("{0},", number);
  13. }
  14. }

以上是关于从IEnumerable创建逗号分隔的列表的主要内容,如果未能解决你的问题,请参考以下文章