public static void Main()
TestObject test = new TestObject();
Console.WriteLine(test.testfld1.GetFieldAttr().Text);
Console.WriteLine(test.testfld2.GetFieldAttr().Text);
Console.WriteLine(test.testfld3.GetFieldAttr().Text);
public static class Extensions
public static FieldAttr GetFieldAttr(this object source)
var test = typeof (TestObject);
var type = test.GetFields()
.FirstOrDefault(x => x.FieldType == source.GetType());
var attribute = type.GetCustomAttribute<FieldAttr>();
[FieldAttr("prop_testfld1")]
public FLDtype1 testfld1 = new FLDtype1();
[FieldAttr("prop_testfld2")]
public FLDtype2 testfld2 = new FLDtype2();
[FieldAttr("prop_testfld3")]
public FLDtype1 testfld3 = new FLDtype1();
public string Value { get; set; }
public Guid Value { get; set; }
public sealed class FieldAttr : System.Attribute
public FieldAttr(string txt)
public string Text { get { return this._txt; } }