public partial class Form1 : Form
private void btndisplay_Click(object sender, EventArgs e)
ArrayList list = new ArrayList();
Although arrayList is never used according to your code.
I take it from your comment that you want to know why
as well at 'what'.
Your first error:
The () means that you are trying to call the constructor for a variable declaration. No such thing exists. Variable declarations do not use (). What you really wanted is:
Which would declare a variable arrayList of type Array. But since you did not assign the variable any value it will have its default value of null. AND
since arrayList is declared within the scope of the form constructor, that is the only place were you could use it.
Your second error comes at the line:
arrayList list = new arrayList();
Which means that you are declaring a variable list of type arrayList and instantiating an instance of that class. Well the problem is that you have not defined what class 'arrayList' is. So you get the type or namespace error. 'arrayList' in your original code would be a variable and could not be instantiated as a new instance of a class. And would not be visible to this method since that variable is scoped to the form constructor.
To actually fix your code depends on what it is that you really want to do. Do you want an Array or an ArrayList? Do you really want a class level or a function level variable? I do not see where you are using the list outside of the function so I would not imagine that you need a class level variable.
The third problem that has not been mentioned is:
as your function is declared to return void then trying to return a list from it, won't work.