PropertyInfo::GetValue Method (Object^)
Returns the property value of a specified object.
Assembly: mscorlib (in mscorlib.dll)
Parameters
- obj
-
Type:
System::Object^
The object whose property value will be returned.
You call the GetValue(Object^) overload to retrieve the value of a non-indexed property; if you try to retrieve the value of an indexed property, the method throws a TargetParameterCountException exception. You can determine whether a property is indexed or not by calling the GetIndexParameters method. If the length of the returned ParameterInfo array is zero, the property is not indexed.
This is a convenience method that provides an implementation for the abstract GetValue(Object^, BindingFlags, Binder^, array<Object^>^, CultureInfo^) method with the BindingFlags parameter set to BindingFlags::Default, the Binder set to null, the object array of index values set to null, and the CultureInfo set to null.
The following example defines a Planet class that has two properties: Name, the name of the planet; and Distance, the planet's distance from Earth. The example instantiates a Planet object that represents the planet Jupiter and passes it to a GetPropertyValues method that displays information about the properties and uses the GetValue method to get the value of each Planet property.
Available since 8
.NET Framework
Available since 4.5
Portable Class Library
Supported in: portable .NET platforms
Windows Phone Silverlight
Available since 8.0
Windows Phone
Available since 8.1