NGWS SDK Documentation  

This is preliminary documentation and subject to change.
To comment on this topic, please send us email at ngwssdk@microsoft.com. Thanks!

FieldInfo.Attributes

Retrieves the attributes associated with this field.

[Visual Basic]
MustOverride Public ReadOnly Property Attributes As FieldAttributes
[C#]
public FieldAttributes Attributes {abstract get;}
[C++]
public: __property virtual FieldAttributes get_Attributes() = 0;
[JScript]
public abstract function get Attributes() : FieldAttributes;

Property Value

Read-only. Retrieves the FieldAttributes for this field.

Remarks

Property representing the Attributes associated with a Member. All members have a set of attributes, which are defined in relation to the specific type of member. The FieldAttributes let the user know if this field is the private field, a static field, etc.

To get the Attributes property, first get the class Type. From the Type, get the FieldInfo. From the FieldInfo, get the Attributes.

Example [C#]

[C#]

public class Myproperty
{
   private string caption = "Default caption";
   public string Caption{
      get{return caption;}
      set{if(caption!=value) {caption = value;}}
   }
}
class Myfieldinfo
{
   public static int Main()
      {
      Console.WriteLine ("\nReflection.FieldInfo");
      Myproperty Myproperty = new Myproperty();
 
      //Get the Type and FieldInfo
      Type MyType = Type.GetType("Myproperty");
      FieldInfo Myfieldinfo = MyType.GetField("caption", BindingFlags.NonPublic);
 
      //Get and Display the FieldInfo.Attributes
      Console.Write ("\nFor {0}.", MyType.FullName);
      Console.Write ("{0}; ", Myfieldinfo.Name);
      FieldAttributes Myfieldattributes = Myfieldinfo.Attributes;
      Console.WriteLine("FieldInfo.Attributes = {0}",
        EnumInfo.ToString(typeof(FieldAttributes),Myfieldattributes));
      
      return 0;
   }
}

This code produces the following output:

Reflection.FieldInfo

For Myproperty.caption;

FieldInfo.Attributes = Private

See Also

FieldInfo Class | FieldInfo Members | System.Reflection Namespace | FieldAttributes