System.Object.FieldSetter C# (CSharp) Method

FieldSetter() private method

private FieldSetter ( String typeName, String fieldName, Object val ) : void
typeName String
fieldName String
val Object
return void
    private void FieldSetter(String typeName, String fieldName, Object val)
    {
        // Extract the field info object
        FieldInfo fldInfo = GetFieldInfo(typeName, fieldName);

        if (fldInfo.IsInitOnly)
            throw new FieldAccessException(Environment.GetResourceString("FieldAccess_InitOnly"));

        // Make sure that the value is compatible with the type
        // of field
        System.Runtime.Remoting.Messaging.Message.CoerceArg(val, fldInfo.FieldType);    

        // Set the value            
        fldInfo.SetValue(this, val);
    }