We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. (Last updated on: November 16, 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback
Platform : WinForms
Category : General

Is there a way to access private and protected members of a class instance?

.NET Reflection can be used to get hold of non-Public members of a class instance. The System.Type class provides various methods that allow you to access the fields/properties/methods for all defined types. Depending on the context, you can use either the typeof(class) operator or the Object.GetType() method to get hold of the System.Type object representing the particular type and then use that type object to access the required member information.

The following code shows how to use the Type.GetField() and FieldInfo.GetValue() methods to determine the value of the ’pasteIndex’ private field implemented by the Diagram.Controller class.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon