To obtain the attributes of an object, you can use the type. getproperty (string, bindingflags) function. Bindingflags specifies the range of the reflection search.
Today, as needed, we decided to change the original case-sensitive method to case-insensitive.Code
Propertyinfo propinfo = Typeof (). Getproperty (name );
Directly change:
Propertyinfo propinfo = Typeof (). Getproperty (name, bindingflags. ignorecase );
I thought it was a success, but no attribute was found at all.
After reading msdn, we found that bindingflags. ignorecase only defines the reflection search method, but also the scope of the reflection search.
So I modified the code again:
Propertyinfo propinfo = Typeof (). Getproperty (name, bindingflags. Public | Bindingflags. Instance | Bindingflags. ignorecase );
To obtain the attributes of an object, you can use the type. getproperty (string, bindingflags) function. Bindingflags specifies the range of the reflection search.
Today, as needed, we decided to change the original case-sensitive method to case-insensitive.
Propertyinfo propinfo = Typeof (). Getproperty (name );
Directly change:
Propertyinfo propinfo = Typeof (). Getproperty (name, bindingflags. ignorecase );
I thought it was a success, but no attribute was found at all.
After reading msdn, we found that bindingflags. ignorecase only defines the reflection search method, but also the scope of the reflection search.
So I modified the code again:
Propertyinfo propinfo = Typeof (). Getproperty (name, bindingflags. Public | Bindingflags. Instance | Bindingflags. ignorecase );