Adding Own Class to WindowsApplication

B

bg_ie

Hi,

I wish to write a WindowsApplication which prompts the user to enter a
set of values in text boxes. I then what to write these values to an
xml file. I have created my own class where these values can be stored
as the application runs, but I am unsure where to declare an object
belonging to this class. Should it be in the program class as a static
member and do I then pass it to my Forms constructor?

Thanks for your help,

Barry.
 
R

Richard Lewis Haggard

This is not a critical question. It could be done multiple ways. Having said
that, good OOP practices generally try to limit the visibility, scope and
lifetime of objects.

If the information is being collected in a child form then the child form,
after verifying the data, would create the Xml serialize object and make use
of it at the time that the user indicated that he was done with the data
entry.

If the information is being collected in the main form then I'd create the
Xml serialize object in the code that handles the user's indication that
data collection was complete.

It is generally more trouble to pass in an already created object to a child
form than it is to make the object locally plus having the object hang
around in places where it is not used just confuses the code.
 
I

Ignacio Machin \( .NET/ C# MVP \)

Hi,

Hi,

I wish to write a WindowsApplication which prompts the user to enter a
set of values in text boxes. I then what to write these values to an
xml file. I have created my own class where these values can be stored
as the application runs, but I am unsure where to declare an object
belonging to this class. Should it be in the program class as a static
member and do I then pass it to my Forms constructor?

If you only will have one instance of this class (there is only one set of
values) you can make it a Singleton.
 

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