Ray Ray - 1 year ago 148
C# Question

Unable to declare an ArrayList

I'm not able to declare an ArrayList. Here's my code. (I'd much rather use Lists, but I'm just trying to understand the concept of an ArrayList).

private void button1_Click(object sender, EventArgs e)
ArrayList salesTotals = new ArrayList();
decimal[] decimalSales = { 1000m, 2000m, 3000m };

foreach (decimal singleSales in decimalSales)

When I compile this, I get this error:

'ArrayList' is a 'namespace' but is used like a 'type'

I'm using the namespace

What is causing this and how do I fix it?

mdm mdm
Answer Source

It sounds like you are using the ArrayList within a namespace itself called ArrayList. The symbol is resolving to the namespace definition, which is invalid in the symbol's context, causing the error you describe.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download