c# - Can Expression.PropertyOrField be used to access a static property or field? -
the documentation of expression
parameter of expression.propertyorfield
states can null
static members:
an expression
type
contains property or field namedpropertyorfieldname
. this cannull
static members.
(emphasis mine)
however, whenever pass null
argumentnullexception
.
the documentation of method contradictory:
- the documentation of
expression
parameter states cannull
static members - the documentation of
argumentnullexception
states thrown ifexpression
null
fact is:
method can't used access static members, documentation of expression
parameter incorrect.
when expression correct type
supplied, method doesn't work expected, because ever looks instance members.
to access static field or property, use expression.makememberaccess
instead.
Comments
Post a Comment