Consider that I have a MemberInfo
object of member MyObject.Field1
, how would I get the full name of this member? I understand that MemberInfo.ReflectedType.FullName + '.' + MemberInfo.Name
would do, but is there any more "native" solution? I would rather not define notations myself. I have also seen notations like MyObject+Abc
as a reference to delegates so I am careful.
1 Answer
I believe MemberInfo.ReflectedType.FullName + '.' + MemberInfo.Name
is fine(till someone provides elegant way). I'd use string.format to make it bit cleaner
string fullMemberName = string.Format("{0}.{1}", member.ReflectedType.FullName, member.Name);
+
notation is used for nested types. In your example if Abc
is nested type of MyObject
name of the type Abc
will be MyObject+Abc
.
MemberInfo.ToString()
not working?TypeA+TypeB
is the CLR notation forTypeB
nested inTypeA
.