How do I know a MemberInfo is static?

  • Thread starter Thread starter deerchao
  • Start date Start date
D

deerchao

Is there any way I can find out a MethodInfo/PropertyInfo/... is
static (which means the same as in C# language here)?

Thanks!
 
Well, one option is the calling convention; static is "Standard",
instance is generally "HasThis" (for C# at least). With PropertyInfo you
might have to get one of the accessors (GetGetMethod / GetSetMethod) to
do this.

There may be other ways, of course...

Marc
 
Well, one option is the calling convention; static is "Standard",
instance is generally "HasThis" (for C# at least). With PropertyInfo you
might have to get one of the accessors (GetGetMethod / GetSetMethod) to
do this.

There may be other ways, of course...

Marc

Thanks, I'll have a try.

I am wondering why wouldn't the microsoft guys add an IsStatic
property for MemberInfo class :(
 
I guess I'm saying that while adding an IsStatic property might have
made it even _more_ convenient, once you head down that path there's
all sorts of attributes they could expose as properties rather than
just having you look at the specific meta-data. Given that the


But... they did. All sorts of attributes. In the MethodBase.Attributes
property no less.

Try (mi.Attributes & MethodAttributes.Static).
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top