PC Review


Reply
Thread Tools Rate Thread

How do I know a MemberInfo is static?

 
 
deerchao
Guest
Posts: n/a
 
      19th Jun 2008
Is there any way I can find out a MethodInfo/PropertyInfo/... is
static (which means the same as in C# language here)?

Thanks!
 
Reply With Quote
 
 
 
 
Marc Gravell
Guest
Posts: n/a
 
      19th Jun 2008
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
 
Reply With Quote
 
deerchao
Guest
Posts: n/a
 
      19th Jun 2008
On Jun 19, 4:44*pm, Marc Gravell <marc.grav...@gmail.com> wrote:
> 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
 
Reply With Quote
 
Ben Voigt [C++ MVP]
Guest
Posts: n/a
 
      18th Jul 2008
> 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).


> information is in fact available, I think the reason "the microsoft
> guys" wouldn't add an IsStatic property is that there's really no
> need to.
> Pete



 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
MemberInfo derived classes Tony Johansson Microsoft C# .NET 1 14th May 2010 10:53 AM
MemberInfo for Attribute target =?Utf-8?B?a2g=?= Microsoft C# .NET 4 30th Oct 2007 12:45 PM
Question about MemberInfo.ReflectedType =?Utf-8?B?UElFQkFMRA==?= Microsoft Dot NET Framework 1 22nd Nov 2006 07:08 PM
MemberInfo Invoke with out object[] stic Microsoft C# .NET 14 1st Aug 2005 05:33 PM
color from Reflection.MemberInfo Milosz Weckowski Microsoft Dot NET Compact Framework 1 23rd Jan 2004 02:14 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 03:26 AM.