以predefined阵列工作 [英] Working with predefined arrays

查看:125
本文介绍了以predefined阵列工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我创建在C#中自己的泛型集合类,和Im存储应该有一个predefined长度列表数组上工作(它应与2的长度开始)。现在,我对如何使其与2的长度开始不知道举例来说,如果我创建一个数组:

I am creating an own generic collection class in C#, and Im working on an array that stores a list that should have an predefined length (It should start with a length of 2). Now I have no idea on how to make it start with a length of 2. For example, if I create an array:

私人INT []号= INT新[20];

private int[] numbers = new int[20];

我如何$ P $所以它为2的长度开始pdefined它的长度?

How do I predefined it length so it starts with a length of 2?

推荐答案

我认为没有理由这样做。然而,你可以用长度创建数组2 - >

I see no reason to do that. However you can create arrays with length 2 ->

私人INT []号= INT新[2];

此外,您还可以使用列表< T> 来做到这一点,而忘记了内存管理? : - )

Also, you can use List<T> to do just that and forget about memory management? :-)

这篇关于以predefined阵列工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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