Good afternoon

I have recently had to switch from using VB.Net to using C#. The software I am trying to write needs to hold a DataSet in memory (consisting of about 5-10 tables). Then depending on user interaction, data will be added to or read out from the DataSet and viewed on screen. My program is not going to have a database but just deserialise the DataSet to file at the end of play.

What is the best way to store this dataset in memory?

I no longer have public variables to use, I've looked into class properties and static classes and I'm pretty confused. Can anyone point me in the right direction?

Regards

303

you can define a c# helper class holding all the public static variables, and having a ClassInitialize static method (mybe with parameters) to initialize all the static variable you'll need.

This methol should be called fom the New procedure of the starting form or from the static void Main from the starting program class.

Hope this helps

Thank you I'm beginning to understand public static variables

I have another question though. We have raised the possibility of having multiple DataSets at once

I'd like to create a 'Case' class so we can initialise multiple objects, each one having it's own DataSet.

Is this possible? It does not seem like I can have DataSet as a property of a class unless it is static, so presumably all instances of the object would need to share the same DataSet?

Will I need to put all my data in one dataset and just have references as a private property?

Any instantiable object can have his own instantiated dataset.
Ie: each form in an application can have his own dataset. When you write var f = new form1; a new instance of the form is created and, if the form has a var ds = new dataset; this willalso be instantiated with th form.

The datasets ca be passed by reference so there is no problem to deal with several public datasets from instantiated objects.
Any way, i am almost sure you can define a

DataSet PublicDataset {get;set;}

and it will work

Hope this helps

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.