Defining a Property with Reflection Emit

A property is defined using the TypeBuilder.DefineProperty method. DefineProperty returns a PropertyBuilder. The DefineProperty method requires the caller to specify the property name, the signature of the property, the property attributes (using the PropertyAttributes enumeration), and the backing field.

The PropertyBuilder class allows the caller to specify the getter method, the setter method, and any other methods.

The default value of the property can be set using PropertyBuilder.SetConstant.

Was this page helpful?
(1500 characters remaining)
Thank you for your feedback

Community Additions

© 2015 Microsoft