C# arrays....

  • Thread starter Thread starter genc ymeri
  • Start date Start date
G

genc ymeri

Do C# arrays expand their length in run time ? for instance, in pascal, to
expand the length with one, I could do it like :

Setlength(MyArray, Length(MyArray)+1);

Can I do same thing in C# ?

Thanks
 
No, you cannot. If you need this functionality, look for something more
advanced like System.Collections.ArrayList.
 
In C#, arrays are not dynamically resizable. To get this functionality, you
can use an ArrayList, which is in the System.Collections namespace. With an
ArrayList, you could keep adding and removing elements without having to
worry about manually setting the size (if you don't want to). It also has a
method which could return an array containing the elements if required.

See the following link.
http://msdn.microsoft.com/library/e...CollectionsArrayListClassTopic.asp?frame=true

Hope this helps.
 
thanks a lot.

Jeffrey Wynn said:
In C#, arrays are not dynamically resizable. To get this functionality, you
can use an ArrayList, which is in the System.Collections namespace. With an
ArrayList, you could keep adding and removing elements without having to
worry about manually setting the size (if you don't want to). It also has a
method which could return an array containing the elements if required.

See the following link.
http://msdn.microsoft.com/library/e...CollectionsArrayListClassTopic.asp?frame=true

Hope this helps.
 
Back
Top