TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
James Webb
NA
11
9.6k
Global Variables N00BIE Help!
Jul 18 2014 5:43 PM
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
Reply
Answers (
2
)
ForEach for Two List asp.net MVC
Pass the SelectedItems details of ListBox to another page