You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The search for `name` is case-sensitive. The search includes public static and public instance properties.
10
+
The following guidance applies to all overloads:
13
11
14
-
A property is considered public to reflection if it has at least one accessor that is public. Otherwise the property is considered private, and you must use <xref:System.Reflection.BindingFlags.NonPublic?displayProperty=nameWithType>|<xref:System.Reflection.BindingFlags.Instance?displayProperty=nameWithType>|<xref:System.Reflection.BindingFlags.Static?displayProperty=nameWithType> (in Visual Basic, combine the values using ` Or `) to get it.
12
+
- A property is considered public to reflection if it has at least one accessor that is public. Otherwise the property is considered private, and you must use <xref:System.Reflection.BindingFlags.NonPublic?displayProperty=nameWithType>|<xref:System.Reflection.BindingFlags.Instance?displayProperty=nameWithType>|<xref:System.Reflection.BindingFlags.Static?displayProperty=nameWithType> (in Visual Basic, combine the values using ` Or `) to get it.
13
+
- If the current <xref:System.Type> represents a constructed generic type, this method returns the <xref:System.Reflection.PropertyInfo> with the type parameters replaced by the appropriate type arguments.
14
+
- If the current <xref:System.Type> represents a type parameter in the definition of a generic type or generic method, this method searches the properties of the class constraint.
15
15
16
-
If the current <xref:System.Type> represents a constructed generic type, this method returns the <xref:System.Reflection.PropertyInfo> with the type parameters replaced by the appropriate type arguments.
If the current <xref:System.Type> represents a type parameter in the definition of a generic type or generic method, this method searches the properties of the class constraint.
18
+
The search for `name` is case-sensitive. The search includes public static and public instance properties.
19
19
20
20
Situations in which <xref:System.Reflection.AmbiguousMatchException> occurs include the following:
21
21
@@ -24,8 +24,6 @@ Situations in which <xref:System.Reflection.AmbiguousMatchException> occurs incl
A property is considered public to reflection if it has at least one accessor that is public. Otherwise the property is considered private, and you must use <xref:System.Reflection.BindingFlags.NonPublic?displayProperty=nameWithType>|<xref:System.Reflection.BindingFlags.Instance?displayProperty=nameWithType>|<xref:System.Reflection.BindingFlags.Static?displayProperty=nameWithType> (in Visual Basic, combine the values using ` Or `) to get it.
28
-
29
27
The following <xref:System.Reflection.BindingFlags> filter flags can be used to define which properties to include in the search:
30
28
31
29
- You must specify either `BindingFlags.Instance` or `BindingFlags.Static` in order to get a return.
@@ -38,20 +36,12 @@ The following <xref:System.Reflection.BindingFlags> modifier flags can be used t
38
36
-`BindingFlags.IgnoreCase` to ignore the case of `name`.
39
37
-`BindingFlags.DeclaredOnly` to search only the properties declared on the <xref:System.Type>, not properties that were simply inherited.
40
38
41
-
See <xref:System.Reflection.BindingFlags?displayProperty=nameWithType> for more information.
42
-
43
-
If the current <xref:System.Type> represents a constructed generic type, this method returns the <xref:System.Reflection.PropertyInfo> with the type parameters replaced by the appropriate type arguments.
44
-
45
-
If the current <xref:System.Type> represents a type parameter in the definition of a generic type or generic method, this method searches the properties of the class constraint.
46
-
47
39
Situations in which <xref:System.Reflection.AmbiguousMatchException> occurs include the following:
48
40
49
41
- A type contains two indexed properties that have the same name but different numbers of parameters. To resolve the ambiguity, use an overload of the <xref:System.Type.GetProperty%2A> method that specifies parameter types.
50
42
- A derived type declares a property that hides an inherited property with the same name, using the `new` modifier (`Shadows` in Visual Basic). To resolve the ambiguity, include <xref:System.Reflection.BindingFlags.DeclaredOnly?displayProperty=nameWithType> to restrict the search to members that are not inherited.
A property is considered public to reflection if it has at least one accessor that is public. Otherwise the property is considered private, and you must use <xref:System.Reflection.BindingFlags.NonPublic?displayProperty=nameWithType>|<xref:System.Reflection.BindingFlags.Instance?displayProperty=nameWithType>|<xref:System.Reflection.BindingFlags.Static?displayProperty=nameWithType> (in Visual Basic, combine the values using ` Or `) to get it.
Although the default binder does not process <xref:System.Reflection.ParameterModifier> (the `modifiers` parameter), you can use the abstract <xref:System.Reflection.Binder?displayProperty=nameWithType> class to write a custom binder that does process `modifiers`. `ParameterModifier` is only used when calling through COM interop, and only parameters that are passed by reference are handled.
57
47
@@ -68,9 +58,9 @@ The following table shows what members of a base class are returned by the `Get`
68
58
69
59
Notes:
70
60
71
-
1. Hide-by-name-and-signature considers all of the parts of the signature, including custom modifiers, return types, parameter types, sentinels, and unmanaged calling conventions. This is a binary comparison.
72
-
2. For reflection, properties and events are hide-by-name-and-signature. If you have a property with both a get and a set accessor in the base class, but the derived class has only a get accessor, the derived class property hides the base class property, and you will not be able to access the setter on the base class.
73
-
3. Custom attributes are not part of the common type system.
61
+
- Hide-by-name-and-signature considers all of the parts of the signature, including custom modifiers, return types, parameter types, sentinels, and unmanaged calling conventions. This is a binary comparison.
62
+
- For reflection, properties and events are hide-by-name-and-signature. If you have a property with both a get and a set accessor in the base class, but the derived class has only a get accessor, the derived class property hides the base class property, and you will not be able to access the setter on the base class.
63
+
- Custom attributes are not part of the common type system.
74
64
75
65
The following <xref:System.Reflection.BindingFlags> filter flags can be used to define which properties to include in the search:
76
66
@@ -84,12 +74,6 @@ The following <xref:System.Reflection.BindingFlags> modifier flags can be used t
84
74
-`BindingFlags.IgnoreCase` to ignore the case of `name`.
85
75
-`BindingFlags.DeclaredOnly` to search only the properties declared on the <xref:System.Type>, not properties that were simply inherited.
86
76
87
-
See <xref:System.Reflection.BindingFlags?displayProperty=nameWithType> for more information.
88
-
89
-
If the current <xref:System.Type> represents a constructed generic type, this method returns the <xref:System.Reflection.PropertyInfo> with the type parameters replaced by the appropriate type arguments.
90
-
91
-
If the current <xref:System.Type> represents a type parameter in the definition of a generic type or generic method, this method searches the properties of the class constraint.
92
-
93
77
## Indexers and default properties
94
78
95
79
Visual Basic, C#, and C++ have simplified syntax for accessing indexed properties and allow one indexed property to be a default for its type. For example, if the variable `myList` refers to an <xref:System.Collections.ArrayList>, the syntax `myList[3]` (`myList(3)` in Visual Basic) retrieves the element with the index of 3. You can overload the property.
0 commit comments