C# c中数组的整数列表#
我有一个名为C# c中数组的整数列表#,c#,C#,我有一个名为MyList的int列表。在javascript中,当我们对一个数字数组调用toString时,它将其转换为一个字符串,每个数字用逗号分隔;我希望在C#中也能做到这一点 我尝试调用.ToString()到列表,但它返回了列表的类型。我正在考虑一个循环,循环遍历列表并将每个元素连同逗号一起添加到stringbuilder,然后将.ToString()添加到stringbuilder 这是最好的方法吗 谢谢。使用: 使用: 您可以使用该方法使用分隔符“内爆”阵列 e、 g: 您可以使用该
MyList
的int列表。在javascript中,当我们对一个数字数组调用toString
时,它将其转换为一个字符串,每个数字用逗号分隔;我希望在C#中也能做到这一点
我尝试调用.ToString
()到列表,但它返回了列表的类型。我正在考虑一个循环,循环遍历列表并将每个元素连同逗号一起添加到stringbuilder,然后将.ToString()添加到stringbuilder
这是最好的方法吗
谢谢。使用:
使用:
您可以使用该方法使用分隔符“内爆”阵列
e、 g:
您可以使用该方法使用分隔符“内爆”阵列
e、 g:
请尝试使用以下代码:
List<int> MyList = new List<int>();
MyList.Add(1);
MyList.Add(2);
MyList.Add(3);
MyList.Add(4);
MyList.Add(5);
MyList.Add(6);
var m = string.Join(",", MyList);
MessageBox.Show(m.ToString());
List MyList=new List();
添加(1);
添加(2);
添加(3);
添加(4);
添加(5);
添加(6);
var m=string.Join(“,”,MyList);
Show(m.ToString());
尝试使用以下代码:
List<int> MyList = new List<int>();
MyList.Add(1);
MyList.Add(2);
MyList.Add(3);
MyList.Add(4);
MyList.Add(5);
MyList.Add(6);
var m = string.Join(",", MyList);
MessageBox.Show(m.ToString());
List MyList=new List();
添加(1);
添加(2);
添加(3);
添加(4);
添加(5);
添加(6);
var m=string.Join(“,”,MyList);
Show(m.ToString());
List<int> MyList = new List<int>();
MyList.Add(1);
MyList.Add(2);
MyList.Add(3);
MyList.Add(4);
MyList.Add(5);
MyList.Add(6);
var m = string.Join(",", MyList);
MessageBox.Show(m.ToString());