Hello all,

i want to creat a list of an object
so i used ArrayList in C#


after declaring a class book
i declare the array list as follwing:

private ArrayList mobileStore = new ArrayList();

then i have an object of class , say Mobile

Mobile m1;

and finally i tried to add the object m1 to the array list

mobileStore.Add(m1);
but the error occurs !!


Invalid token '(' in class, struct, or interface member declarationInvalid token ')' in class, struct, or interface member declaration

-------------------

then i tried anoter way :

List<Mobile> store = new List<Mobile>();

but the problem was the same ????


how can i fix it ?

Use curly braces to create a body of class, methods, loop etc.

class Sample
 {
     public void Add()
     {
       //
     }
 }

Use curly braces to create a body of class, methods, loop etc.

class Sample
 {
     public void Add()
     {
       //
     }
 }

i already did !!
i have 2 classes !!
one to define the Mobile class with its attributes and properties methods !!
2nd to manipulate information of mobile store !!!


><

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.