Reputation: 3386
When calling Type.GetMember(string name, MemberTypes type, BindingFlags bindingAttr)
, when is this information not enough to find zero or one members, assuming bindingAttr
is BindingFlags.Default
(i.e. Doesn't matter). What kinds of members will need to be indivdually disambiguated through other properties?
Upvotes: 0
Views: 172
Reputation: 100537
Multiple overrides will return multiple results:
class X
{
public int GetX(){ return 1;}
public int GetX(string s){ return 2;}
}
var r = typeof(X).GetMember("GetX", MemberTypes.Method,
BindingFlags.Instance|BindingFlags.Public); // 2 items
Note that specifying Default
will always return 0 items - you need at least Instance
or Static
. See Type.GetMember:
You must specify either BindingFlags.Instance or BindingFlags.Static in order to get a return.
Upvotes: 2