Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using singleton to pass property values? [closed]
- public class ShareArray
- {
- private System.Collections.ArrayList arrayList;
- private string pass;
- private string userName
- #region Property
- public System.Collections.ArrayList ArrayList { get{return arrayList;}}
- public string UserName { get{return userName;} set{userName = value;}}
- public string Pass { get{return pass;} set{pass = value;}}
- #endregion
- #region Imp. signletone
- private static ShareArray instance;
- public static ShareArray Instance
- {
- get
- {
- if (instance == null)
- {
- instance = new ShareArray();
- }
- return instance;
- }
- }
- private ShareArray()
- {
- arrayList = new System.Collections.ArrayList();
- }
- #endregion
- }
- ShareArray.Instance.Pass = "pass";
- ShareArray.Instance.UserName = "user name";
- namespace SingletonExample
- {
- public seal class Singleton
- {
- private static Singleton _instance;
- private static object _syncInstance = new Object();
- private static ArrayList _someList = new ArrayList();
- private static Singleton GetInstance()
- {
- get
- {
- if (_instance == null)
- {
- lock(_syncInstance)
- {
- _instance = new Singleton();
- }
- }
- return _instance;
- }
- }
- public ArrayList ArrayList
- {
- get
- {
- return _someList;
- }
- set
- {
- _someList = value;
- }
- }
- public Object GetValue
- {
- get
- {
- return _someList[value];
- }
- }
- }
- }
Add Comment
Please, Sign In to add comment