Click to See Complete Forum and Search --> : Array in C#


pre_wreck
March 4th, 2008, 10:03 PM
What is the equivalent code for this?

private procList As New ArrayList()

I have a problem in accessing the array list in c#.

please help.

thank you.

jon.borchardt
March 4th, 2008, 10:22 PM
I would use:

List<type> x = new List<type>();
eg. List<string> x = new List<string>();

...

or

ArrayList al = new ArrayList();

or

string[] sa = new string[];

pre_wreck
March 4th, 2008, 11:17 PM
I would use:

List<type> x = new List<type>();
eg. List<string> x = new List<string>();

...

or

ArrayList al = new ArrayList();

or

string[] sa = new string[];

It doesn't work!
Coz i want that to implement it here.


private procList = new ArrayList();

if ((procList != null))
{
int i;
for (i = 0; i <= procList.Count - 1; i++)
{
KingLeon.Help.CloseHelp((Diagnostics.Process)procList(i));
}
}


How would I do that?

jon.borchardt
March 5th, 2008, 12:04 AM
I need more info
why cant you use a generic?
it is because the api requires an arraylist?

if so, why can you not just use an arraylist?

what is not working?

Rudegar
March 5th, 2008, 02:26 AM
KingLeon.Help.CloseHelp((Diagnostics.Process)procList(i));
should be
KingLeon.Help.CloseHelp((Diagnostics.Process)procList[i]);

problem is that you are using some vb syntax thing

nabeelisnabeel
March 5th, 2008, 06:14 AM
What is the equivalent code for this?

private procList As New ArrayList()

I have a problem in accessing the array list in c#.

please help.

thank you.

Equivalent is
private ArrayList procList = new ArrayList();

and you will use it as

procList.Add(someObject);