Tech
Forums
Jobs
Books
Events
Interviews
Live
More
Learn
Training
Career
Members
Videos
News
Blogs
Login
Sign Up
Ask Question
7
Reply
initializing and accessing dictionary globally
rohit pol
Apr 21 2012 11:12 PM
5.8k
Reply
Hi All,
I am loading Dictionary object with some values and wanted to access it throughout my project, how can I do that. Please see explained below.
public class class1{
class2 cl2 = new
class2();
cl2.
loadDataFile();
}
public class class3{
string str = "______________________";
class2 cls2 = new
class2();
cls2.
getStrings(str);
}
public class
class2{
protected Dictionary<string, string>
store
=
new Dictionary<string, string>();
public void
loadDataFile()
{
//logic to load data from file on certain
//conditions and store it in '
store
' Dictionary
object declared above.
}
public string
getStrings(sring str)
{
//Here I will access elements of '
store
'.
//I get '0' element. How to get elements here.
}
}
Thanks,
Upload Source Code
Select only zip and rar file.
Post
Reset
Cancel
Answers (
7
)
Next Recommended Forum
Problem accessing link by using HttpWebRequest or WebBrowser
Https SSL login and PDF download