创建一个固定大小的数组. [英] Creating A fixed size array.

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

问题描述

HI 我想创建一个固定尺寸.
例如,如果我创建了一个大小为4的数组,这会提高值.
并且我只有三个值可以分配给我.那么它应该将4索引作为null返回给我.

HI i want to create a fix size.
Which on assingning value for eg if i create an array of size 4.
and i have only Three values to assign Then it should return the 4 index as null to me.

推荐答案

string[] myValues = new string[4];



您将有一个由四个字符串组成的固定大小的数组,并且每个数组元素都初始化为null.

如果创建任何数字类型的数组,则元素初始化为0-所有其他对象类型初始化为null.

您甚至可以通过编写一些代码并在调试器下运行它,甚至对.Net中最基本的数组知识也可以自己解决这个问题.



You will have a fixed-size array of four strings, and each array element is initialized to null.

If you create an array of any numeric type, the elements initialize to 0 - all other object types initialize to null.

You could have figured this out on your own with even the most rudimetary knowledge of arrays in .Net simply by writing some code and running it under the debugger


您的意思是,但也许如果您创建包含4个元素的数组,然后将其填充为null.然后,如果仅分配3个值,则未使用的值将返回null.

如果这样做没有帮助,那么我建议您尝试重新表述您的问题.祝你好运.
I''m not sure eactly what you mean, but maybe if you create the array with 4 elements, then fill it with nulls. Then if you only assign 3 values, the ones you have not used will return null.

If this does not help, then I suggest you try to re-phrase your question. Best of Luck.


这篇关于创建一个固定大小的数组.的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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