determine if type is not .net type

  • Thread starter Thread starter John A Grandy
  • Start date Start date
J

John A Grandy

Short of brute force , how to determine if a type is not a .net type ...
e.g. a custom type, such as an enum ...
 
If you mean to separate types that the core libraries define
(System.dll, etc) from your own types, then there isn't anything built
in. The most generic approach would be to check the declaring assembly
against a list that you pre-define (or perhaps use the strong name
etc).

Marc
 
It depends precisely what you mean - it's not entirely clear. If you just
want to know whether the type is an enum or not, check GetType().IsEnum. If
you mean "is it something other than the primitive types int, bool, string
etc." you could check GetType().IsPrimitive or GetType().GetTypeCode(). If
you mean "is it something defined in the framework class library or not",
then you have to try something along the lines of what Marc says.
 
That's what I was afraid of.

You'd think they'd build this in , it's such an obvious need.
 
Indeed - actually, I like that fundamentally there is no distinction,
and all types are (largely) equal citizens...

Marc
 

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