Tech
Forums
Jobs
Books
Events
Live
Interviews
More
Learn
Training
Career
Members
Videos
News
Blogs
Login
Sign Up
Ask Question
2
Reply
Global Variables N00BIE Help!
James Webb
Jul 18 2014 5:43 PM
624
Reply
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
Upload Source Code
Select only zip and rar file.
Post
Reset
Cancel
Answers (
2
)
Next Recommended Forum
ForEach for Two List asp.net MVC
Pass the SelectedItems details of ListBox to another page