Note
If a matching property could be found and the invocation itself has thrown an exception, then this method also throws an exception instead of returning .
public static bool TryGetProperty(
Object instance,
string propertyName,
out Object?? value,
params Object?[]? indexParameters
)
Public Shared Function TryGetProperty (
instance As Object,
propertyName As String,
<OutAttribute> ByRef value As Object,
ParamArray indexParameters As Object()
) As Boolean
public:
static bool TryGetProperty(
Object^ instance,
String^ propertyName,
[OutAttribute] Object^% value,
... array<Object^>^ indexParameters
)
static member TryGetProperty :
instance : Object *
propertyName : string *
value : Object byref *
indexParameters : Object[] -> bool
propertyName can refer public and non-public properties. To avoid ambiguity (in case of indexers), this method gets all of the properties of the same name and chooses the first one for which the provided indexParameters match.
If you already have a PropertyInfo instance use the GetProperty(Object, PropertyInfo, ReflectionWays, Object) method for better performance.
For getting the property this method uses the TypeDescriptor way for ICustomTypeDescriptor implementations and the DynamicDelegate way otherwise.