473,405 Members | 2,141 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,405 software developers and data experts.

Array List Global Variable

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
1 6033
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

15
by: Bob | last post by:
I've tried everything; and I can't seem to get past this VERY (seemingly) simply problem. I want to work with an array variable within a function(s). I can't get it to work; if I: 1) global...
19
by: deko | last post by:
I'm kind of lost on this one - I need to modify 2 files based on user input: $data_array = file($data_file); $counter_array = file($counter_file); // There is a line-for-line relationship...
22
by: nobody | last post by:
hello everybody, is there a way of creating an array with help of a function that would accept the name of this array as a parameter and then create global Array type variable of that name? so...
15
by: Geoff Cox | last post by:
Hello, Can I separately declare and initialize a string array? How and where would I do it in the code below? It was created using Visual C++ 2005 Express Beta 2 ... In C# I would have ...
8
by: Paul in Toronto | last post by:
Got this assignment in my VB .NET class. The program's basically a picture viewer that lets you add your pictures to an array so you can cycle through them once the file's been opened. So you...
12
by: a | last post by:
def fn(): for i in range(l) global count count= .... how do i declare count to be global if it is an array subsequently i should access or define count as an array error:
45
by: VK | last post by:
(see the post by ASM in the original thread; can be seen at <http://groups.google.com/group/comp.lang.javascript/browse_frm/thread/3716384d8bfa1b0b> as an option) As that is not in relevance to...
8
by: desktop | last post by:
I am simulating a display that consists of 20x20 pixels. All pixels are per default white but I would like to be able to turn on some or all the pixels. My idea was to create a 3 dimensional...
5
by: Immortal Nephi | last post by:
I would like to design an object using class. How can this class contain 10 member functions. Put 10 member functions into member function pointer array. One member function uses switch to call...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.