c# - 在 C# 中动态创建数组

标签 c#

<分区>

如何在 C# 中动态创建数组?

最佳答案

我想在 Natrium 的回答中补充一点,通用集合也支持这种 .ToArray() 方法。

List<string> stringList = new List<string>();
stringList.Add("1");
stringList.Add("2");
stringList.Add("3");
string[] stringArray = stringList.ToArray();

关于c# - 在 C# 中动态创建数组,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/881133/

相关文章:

c# - 如何使用 Microsoft.Management.Infrastructure (MMI) 而不是 System.Management 进行本地 WMI 查询

c# - 在每个请求上验证 OpenId IdToken

c# - 如何在控制台应用程序中打开一个窗口?

C# 将 RichTextBox 中的字符串的一部分加粗

c# - System.Speech.Recognition 选择识别配置文件

c# - 在 C# 解决方案中,您在哪里声明解决方案范围的枚举?

c# - C# 中的间隔容器

c# - 为什么以下 sql 查询会导致列名无效?

c# - C#中使用AppDomain动态加载卸载dll

c# - 如何在 ApiController 中检索 POST 正文数据?