1

I have written a App that uses a simple form to collect some data from the user. What is the easiest way of making this data availbel to all the classes outside the form?

Thanks

Daniel

0

4 Answers 4

4

Encapsulate the data in a class and pass an instance of that class from your form to the other classes.

Sign up to request clarification or add additional context in comments.

Comments

1

The simplest was I can think of (although you have to be careful) is to create a static class with static public variables. Set those variables from the form data, and everything else can access it. You don't have data persistence, and you have to be careful about other classes updating it, but it will expose the values to all other classes in the program.

Comments

1

You could persist the form input to a database and then access through the repository pattern, for example.

Comments

0

I'd suggest keeping it in a xml file on users computer. That way, it would be very hard to change the data unless you change the xml again.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.