// 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.Reflection; namespace E { public class BadWay { public static readonly string number_1 = "This is number 1"; public static readonly string number_2 = "This is number 2"; public static void Main(string[] args) { int iResult = 1; string newVar = "number_" + iResult; string val = (string)typeof(BadWay).GetField(newVar, BindingFlags.Static | BindingFlags.Public).GetValue(null); Console.WriteLine(val); } } }