This is a super newbie question, I’ve been programming for a while, but am just learning OOP.
I have a class that works with user input via the C# console.
There are different methods in this class to gather different input sets.
I have another class that takes these input sets and puts them in a database.
What is the best way to pass the input from my input class to my database insert class?
My guess would be:
Array1[] = inputClass.GetParameterSet1();
DatabaseInsertClass.InsertIntoDatabase1(Array1[]);
Is there anything wrong with this or is there a better way to do this? Should I even have two classes (The database class could also take the user input)?
You should have a “data” class, that represents all of your parameters.
Your GetParameters class should create an instance of this class.
Your InsertDatabase class should accept an instance of this class.
Additionally, you could use a generic list to pass more than once instance of the data class, you could use an array, but a generic list is much easier to work with.