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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top