列表转换为字符串在C# [英] Convert a list to a string in C#

查看:163
本文介绍了列表转换为字符串在C#的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我要如何转换列表为一个字符串在C#?

当我执行的toString 在一个List对象,我得到:

  

System.Collections.Generic.List`1 [System.String]

解决方案

也许你正在尝试做

 字符串combindedString =的string.join(,myList.ToArray());
 

您可以与您希望通过拆分在列表中的元素的内容替换,

How do I convert a list to a string in C#?

When I execute toString on a List object, I get:

System.Collections.Generic.List`1[System.String]

解决方案

Maybe you are trying to do

string combindedString = string.Join( ",", myList.ToArray() );

You can replace "," with what you want to split the elements in the list by.

这篇关于列表转换为字符串在C#的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆