This code works:
public void MyMethod()
{
List<Class> classList= new List<Class>();
classList.Add(new Class { "set properties" });
}
But what about the code below, when the object (aclass) is filled and comes from the outside of the MyMethod:
public void MyMethod()
{
List<Class> classList= new List<Class>();
Class class = (Class)aclass // "aclass : of type Object"
classList.Add(class);
}
All the items in the list will be the same, as the last item. But I want to add another objects to the list and then use them in another place.