CSharp examples for System.Reflection:FieldInfo
Find Field Throughout Hierarchy
using System.Reflection; using System.Collections.Generic; using System;/*from w ww .ja v a2 s .c om*/ public class Main{ public static FieldInfo FindFieldThroughoutHierarchy(Type type, string name) { FieldInfo field = type.GetField(name, BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.DeclaredOnly); if (field == null && type.GetCustomAttributes(_includeBaseAttributeType, false).Length > 0) { field = FindFieldThroughoutHierarchy(type.BaseType, name); } return field; } }