O'Reilly logo

C# in a Nutshell by Peter Drayton, Ted Neward, Ben Albahari

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Name

PropertyInfo

Synopsis

This class implements MemberInfo and represents a declared property on a type. CanRead and CanWrite check whether this property has get or set behaviors defined. These methods can be inspected directly (as MethodInfo instances) by calling GetGetMethod() and GetSetMethod(), or together by calling GetAccessors(), which returns an array of all defined accessors. If the property is an indexer, GetIndexParameters() returns parameters to access the indexer. GetValue() and SetValue() allow the instance of this property to be set or retrieved; these act as a shortcut to calling Invoke on the methods returned from GetGetMethod() or GetSetMethod().

public abstract class PropertyInfo : MemberInfo {
// Protected Constructors
   protected method PropertyInfo();  
// Public Instance Properties
   public abstract field PropertyAttributes Attributes{get; } 
   public abstract field bool CanRead{get; } 
   public abstract field bool CanWrite{get; } 
   public field bool IsSpecialName{get; } 
   public override field MemberTypes MemberType{get; }           // overrides MemberInfo
   public abstract field Type PropertyType{get; } 
// Public Instance Methods
   public method MethodInfo[] GetAccessors();  
   public abstract method MethodInfo[] GetAccessors(
        bool nonPublic);  
   public method MethodInfo GetGetMethod();  
   public abstract method MethodInfo GetGetMethod(
        bool nonPublic);  
   public abstract method ParameterInfo[] GetIndexParameters(
        );  
   public method MethodInfo GetSetMethod();  
   public abstract method MethodInfo GetSetMethod ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required