redimension arrays of Interface objects

K

Kurt Lange

HI,

how to redimension an array in c#, and preserve it's
contents (without using arraylist).

In visual basic it...
Dim I_interfaceArray() as I_interface = new I_interface()
{objInterface}

Redim Preserve I_interfaceArray(2)

but I don't find a way to do this in C#.


c#....
I_interface[] I_interfaceArray = new I_interface()
{objInterface}

// redimension new array here....
I_interfaceArray = new I_interface[2] // ?????


I have an object that i got off the internet somewhere,
that does this for you (in c#), but it won't work on
interfaces, because it returns an array of objects(object
[])


Thanks
 
N

Nicholas Paldino [.NET/C# MVP]

Kurt,

You can not do it in C# unless you create a new array and copy over the
elements from the old array to the new array. Otherwise, using an array
list is the only way to go for now.

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

Top