O'Reilly logo

Microsoft® .NET Compact Framework Kick Start by Ronnie Yates, Erik Rubin

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

Using Reflection to Manipulate Object State

The Reflection API provides the ability to manipulate an object's state, meaning its properties and fields. Using the Reflection API, you can call property accessors as well as directly change the value of an object's fields.

The two classes that represent fields and properties are the FieldInfo class and the PropertyInfo class, respectively. As with most of the reflection classes, you first have to search and discover a FieldInfo or PropertyInfo object before it can be invoked. Again, the Type class provides methods for discovering both fields and properties.

Discovering a Type's Field Information by Using the GetFields method

The Type.GetFields method has two overloads. One overload takes no parameters ...

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