Solved

How do I create an "array" of variables (e.g. Variable1, Variable2, Variable3 where the number of variables and their values is dynamic)?

Posted on 2009-04-03
3
254 Views
Last Modified: 2013-11-07
I wanted to know how I could create a collection of MemoryStream objects where the number of individual MemoryStreams that need to exist is not known ahead of time.


MemStream1
MemStream2
MemStream4
etc.
0
Comment
Question by:endrec
3 Comments
 
LVL 9

Accepted Solution

by:
kprestage earned 500 total points
ID: 24064033
If you are using .Net 2.0, how bout using a generic list instead?  List<System.IO.MemoryStream> x = new List<System.IO.MemoryStream>;

x.Add(New System.IO.MemoryStream());
0
 

Author Comment

by:endrec
ID: 24064114
Yes, I am using .NET 2.0.  I will try this!
0
 
LVL 10

Expert Comment

by:MaxOvrdrv2
ID: 24065633
Do you have a way of knowing the number of memory streams at the point of creating the array?

you can always use redim preserve when face with a situation like that.

example:

for i=0 to count(options)
  Redim Preserve thearr(i)
  thearr(i)=MemoryStream(i)
next

done.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

For those of you who don't follow the news, or just happen to live under rocks, Microsoft Research released a beta SDK (http://www.microsoft.com/en-us/download/details.aspx?id=27876) for the Xbox 360 Kinect. If you don't know what a Kinect is (http:…
A long time ago (May 2011), I have written an article showing you how to create a DLL using Visual Studio 2005 to be hosted in SQL Server 2005. That was valid at that time and it is still valid if you are still using these versions. You can still re…
Windows 10 is mostly good. However the one thing that annoys me is how many clicks you have to do to dial a VPN connection. You have to go to settings from the start menu, (2 clicks), Network and Internet (1 click), Click VPN (another click) then fi…
Edureka is one of the fastest growing and most effective online learning sites.  We are here to help you succeed.

911 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now