this is my class named "Objek".
public class Objek
{
public int id;
public int tipe;
public int bentuk;
public List<int> x { get; set; }
public List<int> y { get; set; }
public int xC { get; set; }
public int yC { get; set; }
public Color Warna { get; set; }
public Objek()
{
this.Warna = Color.Black;
this.x = new List<int>();
this.y = new List<int>();
}
public Objek(int tipe, int bentuk)
{
this.tipe = tipe;
this.bentuk = bentuk;
this.Warna = Color.Black;
this.x = new List<int>();
this.y = new List<int>();
}
}
then in the form1.cs I declared this globally (outside any method):
Objek temp = new Objek();
after I input the value of the "temp", I stored it to a List:
List<Objek> Objek = new List<Objek>();
with Objek.Add(temp);
the problem is whenever I changed one of the element's attribute value (ex: Objek[0].Warna = Color.Red
) after stored more than 1 "temp" object, all Objek[0, 1, ..., n].Warna
also changed to Red.
Can someone explain me where is my fault in these code?