2
Answers

Global Variables N00BIE Help!

James Webb

James Webb

10y
633
1
Hi Guys,
 
So I'm still very new to C# and I'm currently making a forms application in Visual Studio 2013. I have a program that will display 30 DVD's to a user and the user can add them to a wish list and then there are admin controls too. I have a DVD class and an INVENTORY class. The Inventory class holds a List of the DVD objects.
 
The problem I have is that I would like to be able to access the classes I have made and used in form1, from other forms without needing to save and load to a file. I have tried making the objects global like this: 
 
namespace Summer_Homework
{
public partial class Form1 : Form
{
 
//Global Variables
public DVD DVDCurrent = new DVD();
public INVENTORY Inventory = new INVENTORY();
 
public Form1()
{
InitializeComponent();
}
But it has not worked. What I would like to know is what is the proper way to pass variables between forms?
 
Any help/input would be very much appreciated.
 
Many Thanks and Kind Regards,
James Webb 
 
Answers (2)