Wednesday, 11 September 2013

How to create only once my static list when create my object again and again

How to create only once my static list when create my object again and again

I have an class and one of the class members is static list that keep all
my object and i only want to create this list (List<myObject> list = new
...) once. what is the best way to do it ?
public class MyObject
{
private string _name;
private static List<Capture> _list;
public MyObject(string name)
{
_name = name;
}
public void start()
{
_list.Add(this);
}
}

No comments:

Post a Comment