System.Type.GetField C# (CSharp) Method

GetField() public method

Searches for the public field with the specified name.
is null. This object is a whose method has not yet been called.
public GetField ( string name ) : FieldInfo
name string The string containing the name of the data field to get.
return FieldInfo
        public FieldInfo GetField(string name)
        {
            return this.GetField(name, BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public);
        }

Same methods

Type::GetField ( string name, BindingFlags bindingAttr ) : FieldInfo

Usage Example

        static DynamicScopeTokenResolver()
        {
            BindingFlags s_bfInternal = BindingFlags.NonPublic | BindingFlags.Instance;
            s_indexer = Type.GetType("System.Reflection.Emit.DynamicScope").GetProperty("Item", s_bfInternal);
            s_scopeFi = Type.GetType("System.Reflection.Emit.DynamicILGenerator").GetField("m_scope", s_bfInternal);

            s_varArgMethodType = Type.GetType("System.Reflection.Emit.VarArgMethod");
            s_varargFi1 = s_varArgMethodType.GetField("m_method", s_bfInternal);
            s_varargFi2 = s_varArgMethodType.GetField("m_signature", s_bfInternal);

            s_genMethodInfoType = Type.GetType("System.Reflection.Emit.GenericMethodInfo");
            s_genmethFi1 = s_genMethodInfoType.GetField("m_methodHandle", s_bfInternal);
            s_genmethFi2 = s_genMethodInfoType.GetField("m_context", s_bfInternal);

            s_genFieldInfoType = Type.GetType("System.Reflection.Emit.GenericFieldInfo", false);
            if (s_genFieldInfoType != null)
            {
                s_genfieldFi1 = s_genFieldInfoType.GetField("m_fieldHandle", s_bfInternal);
                s_genfieldFi2 = s_genFieldInfoType.GetField("m_context", s_bfInternal);
            }
            else
            {
                s_genfieldFi1 = s_genfieldFi2 = null;
            }
        }
All Usage Examples Of System.Type::GetField