Hallo Leute, folgendes Problem liegt vor.
Ich erzeuge eine Liste, die aussieht wie ein Vektor. Der Vektor füge ich zu einer weiteren Liste hinzu, in der alle Vektoren gespeichert werden sollen (also eine Liste von einer Liste).
Mit der ersten Liste möchte ich verschiedene Vektoren erzeugen. Sobald ich den Vektor aber ändere, ändert sich dies in der Liste mit (in der die Vektoren gespeichert werden. Ich möchte mit den Vektoren herumhantieren, ohne dass diese sich jeweils in der Liste ändern.
Nachstehend ein Auszug meine Quellcodes: Aggregation beschreibt eine Liste. Die Liste besteht aus den Zuständen OK,DD,DU,SD,R.
1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25: 26: 27: 28: 29: 30: 31: 32: 33: 34: 35: 36: 37: 38: 39: 40: 41: 42: 43: 44: 45: 46: 47: 48: 49:
| AddStateToList(aggregation); RemoveLastState(aggregation);
public void AddStateToList(List<Aggregationszustand> aggr) { List<Aggregationszustand> hilfsaggregation = new List<Aggregationszustand>(); hilfsaggregation = aggr; aggregationlist.Add(hilfsaggregation); }
public void RemoveLastState(List<Aggregationszustand> aggr) { model.actualchannelcount = model.actualchannelcount - 1; aggr.RemoveAt(aggregation.Count - 1); }
public enum Aggregationszustand { OK, SD, DD, DN, R }
private List<Aggregationszustand> _aggregation = new List<Aggregationszustand>(); private List<List<Aggregationszustand>> _aggregationlist = new List<List<Aggregationszustand>>();
public List<Aggregationszustand> aggregation { get { return this._aggregation; } } public List<List<Aggregationszustand>> aggregationlist { get { return this._aggregationlist; } } |