如何创建无限大小的动态数组 [英] How to create dynamic array with unlimited size

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

问题描述

如何创建大小不受限制的动态数组?

How to create dynamic array with unlimited size?

推荐答案

您不能.您将为此使用List类,以便它可以根据需要调整自身大小.没有无限大小"之类的东西.
You can''t. You would use the List class for that, so that it can resize itself as needed. There''s no such thing as ''unlimited size''.


我找到了解决方案.

创建数组列表.

ArrayList obj = new ArrayList();
//添加项目
obj.Add("name");
i found the solution.

create array list.

ArrayList obj = new ArrayList();
//adding item
obj.Add("name");


考虑IList< t>这是通用的,并自行维护其大小.我认为这可以完成工作.请查看以下有关 IList< t> [
Consider IList<t> which is generic and maintain its size by it self. I think this will do the job. Please see below details about IList<t>[^]

:)


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

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