// Collection of code snippets by Arne Vajhøj // (likely posted to comp.os.vms/INFO-VAX, INFO-TPU, MACRO32, eksperten.dk, newz.dk, LinkedIn or other place sometime between 1990 and now) using System; using System.Collections; namespace E { public struct VT { private int v; public void Update(int v) { this.v = v; } public override string ToString() { return v.ToString(); } } public class MainClass { public static void Main(string[] args) { ArrayList lst = new ArrayList(); lst.Add(new VT()); for(int i = 0; i < lst.Count; i++) { ((VT)lst[i]).Update(123); } Console.WriteLine(lst[0]); foreach(VT o in lst) { o.Update(456); } Console.WriteLine(lst[0]); VT[] a = new VT[1]; a[0] = new VT(); for(int i = 0; i < a.Length; i++) { a[i].Update(123); } Console.WriteLine(a[0]); foreach(VT o in a) { o.Update(456); } Console.WriteLine(a[0]); } } }