I have two forums,Login and Game.
Login is used for logging in and it calls a dictionary from class "Clsdictionary"
So I use this on Form Login.
clsDictionary UserSetCLS = new clsDictionary();
|
Then I add some Values and Keys to that Dictionary in the class,I'm using a class so this dictionary can be global/Shared between all my forms in that application.
ClsDictionary.cs code
public Dictionary<string, string> UserSetSTRING = new Dictionary<string, string>(); public Dictionary<string, int> UserSetINT = new Dictionary<string, int>();
|
Then in form login i add some keys and values
UserSetCLS.UserSetINT.Add("UserID", _UserID); UserSetCLS.UserSetSTRING.Add("UserName", UserName); UserSetCLS.UserSetSTRING.Add("CapitalName", CapitalName);
|
Now I have 3 entries.
1 for UserSetINT
2 for UserSetSTRING
At the end of all my code it switchs to form game.
I try to call back the entries that SHOULD be in the Dictionary
using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Windows.Forms;
namespace Game { public partial class frmCapitalCity : Form { clsDictionary UserSetCLS = new clsDictionary(); string CapitalName; public frmCapitalCity() { InitializeComponent(); }
private void CapitalCity_Load(object sender, EventArgs e) { UserSetCLS.UserSetSTRING.TryGetValue("CapitalName", out CapitalName); } } }
|
So that should take the dictionary entry "CapitalCity" and change the label I have to the string value of that.
But,When i call it back its Null. I'm wondering how could that be? I put it all in another Class so it can be used in every form in my application.
Basicly All i want to do is Get one Value from one forum to another.
On Login the Dictionary count is 3 with those three values and there keys.
When i call it back on Game the count is zero with no Entries!
Can anyone correct me in what i did?
Or
Point me to a tutorial that goes over this Specific detail of what i want to do?
If you need me to clear anything up please post!
Thanks,
Aaron