By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
454,424 Members | 1,316 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 454,424 IT Pros & Developers. It's quick & easy.

Array List Global Variable

P: n/a
I am looking at coverting an application over to C#. Currently I have a
global list varible that needs to be converted. I have tested different
ideas to accomplish the same idea. Ths best way I have found for me is to
create a configuration class with a static array list that is accessed
through static methods. Is there a better way to handle this. This class
is in a DLL if that makes a difference.

public class Configuration
{
private static ArrayList _arraylist;
private static ArrayList List
{
get
{
if (_arraylist == null)
_arraylist = new ArrayList();
return _arraylist;
}
}

public static int Add(string Name, string Value)
{
return List.Add(Name +"="+Value);
}
}
Nov 16 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
You should/could make this Configuration class a Singleton otherwise you
could end up with multiple copies of it running around. Then you do not
make the array list static but you force the user to obtain the Single
instance of the class. If you are not familiar with Singletons there are
some very good examples of how to implement one. Just do a google search
and you will find a lot..

JIM
"Phenix Smith" <ph****@sc.rr.com> wrote in message
news:%2****************@TK2MSFTNGP14.phx.gbl...
I am looking at coverting an application over to C#. Currently I have a
global list varible that needs to be converted. I have tested different
ideas to accomplish the same idea. Ths best way I have found for me is to
create a configuration class with a static array list that is accessed
through static methods. Is there a better way to handle this. This class
is in a DLL if that makes a difference.

public class Configuration
{
private static ArrayList _arraylist;
private static ArrayList List
{
get
{
if (_arraylist == null)
_arraylist = new ArrayList();
return _arraylist;
}
}

public static int Add(string Name, string Value)
{
return List.Add(Name +"="+Value);
}
}

Nov 16 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.