c# - C#中如何将数组的内容打印到标签中

标签 c# arrays label

<分区>

我想显示数组中每个数字之间有逗号的标签的内容。 num1 - num6 是从文本框转换而来的整数变量。 到目前为止,我已经这样做了。

int[] number = new int [6] {num1, num2, num3, num4, num5, num6};

Array.Sort(number);

lblAnswer3.Text = number.ToString();

这段代码的输出是:System.Int32[]

我希望输出为:num1、num2、num3、num4、num5、num6,按升序排列。

最佳答案

您可以使用 string.Join 轻松连接 IEnumerables 和数组:

lblAnswer3.Text = string.Join(", ", number);

关于c# - C#中如何将数组的内容打印到标签中,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26434458/

相关文章:

c# - 显示 'saved' 标签 2 秒然后在 c# asp.net 中隐藏

python-3.x - 如何在循环 pandas 数据帧时标记 matplotlib 散点图中的数据点?

C# JSON.Net 将一个列表中的项目放入另一个列表中

c# - 获取 GridView 的列标题的 css

python - 函数调用后记住数组值

使用 gsub 的 Ruby Regexp 是否有等同于 self 关键字?

c# - 以编程方式提升权限并尽可能更加用户友好

c# - 将假列添加到 Linq Entity Framework 查询

javascript - 将 JSON 数组集合发布到 Asp.net Core Web API

D3.js donut chart 更改节点颜色并将文本标签添加到中间