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
252 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

6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

Join & Write a Comment

In my previous article (http://www.experts-exchange.com/Programming/Languages/.NET/.NET_Framework_3.x/A_4362-Serialization-in-NET-1.html) we saw the basics of serialization and how types/objects can be serialized to Binary format. In this blog we wi…
Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, Just open a new email message.  In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

758 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