// 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.ComponentModel; using System.Reflection; namespace E { public class DynamicTest { public double Z { get; set; } public void Test() { string name = "Z"; string val = "123,456"; PropertyInfo pi = GetType().GetProperty(name); TypeConverter tc = TypeDescriptor.GetConverter(pi.PropertyType); pi.SetValue(this, tc.ConvertTo(val, pi.PropertyType), null); Console.WriteLine(Z); } public static void Main(string[] args) { DynamicTest o = new DynamicTest(); o.Test(); } } }