// 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; using System.Reflection; namespace E { class MyClass { private string a; private string b; private string c; public ArrayList GetAttributes() { ArrayList res = new ArrayList(); FieldInfo[] fields = this.GetType().GetFields(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); foreach(FieldInfo f in fields) { res.Add(f.Name); } return res; } } class MainClass { public static void Main(string[] args) { MyClass o = new MyClass(); ArrayList f = o.GetAttributes(); for(int i = 0; i < f.Count; i++) { Console.WriteLine((String)f[i]); } } } }