定义动态数组 [英] Defining Dynamic Array

查看:127
本文介绍了定义动态数组的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我如何定义一个动态数组在C#?

How can I define a dynamic array in C#?

推荐答案

C#不提供动态数组。相反,它提供了其工作方式相同List类。

C# doesn't provide dynamic arrays. Instead, it offers List class which works the same way.

要使用列表,写在你的文件的顶部:

To use lists, write at the top of your file:

using System.Collections.Generic;

和您要使用清单,写(例如对于字符串):

And where you want to make use of a list, write (example for strings):

List<string> mylist = new List<string>();
mylist.Add("First string in list");

这篇关于定义动态数组的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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