动态长度数组 [英] dynamic length arrays

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

问题描述

本文:
http: //www.c-sharpcorner.com/UploadF...ithArrays.aspx

声称在C#中,数组可以声明为固定长度或

dynamic"。


我不相信他是对的。除了集合/

arraylists之外,你能在C#中使用动态大小的数组吗?请注意,我知道Array.Resize< type>(参见myArray,newsize);用于在.NET 2.0中调整

数组的大小。有没有办法动态调整数组大小,

如Mahesh Chand在他的文章中声称(但没有显示)?


它提到了系统.Array类,它有一个IsFixedSize

属性,所以也许我可以使用它来制作一个动态的数组,其价格为



(我认为Mahesh Chand的文章写得很快,因为他声称

二元搜索无需排序即可使用。我见过

这也适用于VB的其他教程。就像这些东西是

只需写在5分钟后发布。而且我必须注册并登录

写评论以帮助他纠正它。)


Zytan

This article:
http://www.c-sharpcorner.com/UploadF...ithArrays.aspx
claims that "In C#, arrays can be declared as fixed length or
dynamic".

I don''t believe he is correct. With the exception of collections /
arraylists, can you have a dynamically sized array in C#? Note that i
am aware of Array.Resize<type>(ref myArray, newsize); for resizing
arrays in .NET 2.0. Is there a way to resize the array dynamically,
as Mahesh Chand claims (but doesn''t show) in his article?

It mentions the System.Array class, which does hav a IsFixedSize
property, so maybe I can use that to make an array that is dynamic in
size.

(I think Mahesh Chand''s article was written quickly, because he claims
the binary search will work without requirement of sorting. I''ve seen
this in other tutorials for VB, as well. It''s like these things are
just written in 5 minutes and posted. And I have to register and log
in to write a comment to help him correct it.)

Zytan

推荐答案

哦,我已经知道了ArrayList。但是,这篇文章讨论的是关于数组而不是集合的
,这就是ArrayList的内容。


谢谢,


Zytan
Oh, and I already know about ArrayList. But, this article is talking
about arrays, not collections, which is what ArrayList is.

thanks,

Zytan


正确:
http://msdn2.microsoft.com/en-us/lib...fixedsize.aspx


" Array实现IsFixedSize属性,因为

System.Collections.IList接口需要它。
Correct:
http://msdn2.microsoft.com/en-us/lib...fixedsize.aspx

"Array implements the IsFixedSize property because it is required by the
System.Collections.IList interface."


正确: http://msdn2.microsoft.com/en- us / lib ... fixedsize.aspx

>

"数组实现IsFixedSize属性,因为它是

System.Collections.IList接口。
>
"Array implements the IsFixedSize property because it is required by the
System.Collections.IList interface."



好​​的,为了清楚起见,数组的大小是固定的吗? IsFixedSize

属性只是因为它是上述所需的?


Zytan

Ok, just to be clear, arrays are fixed in size? The IsFixedSize
property is only because it is required for the above?

Zytan


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

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