determine if type is not .net type

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • John A Grandy

    determine if type is not .net type

    Short of brute force , how to determine if a type is not a .net type ...
    e.g. a custom type, such as an enum ...


  • Marc Gravell

    #2
    Re: determine if type is not .net type

    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

    Comment

    • Clive Dixon

      #3
      Re: determine if type is not .net type

      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().IsEnu m. If
      you mean "is it something other than the primitive types int, bool, string
      etc." you could check GetType().IsPri mitive or GetType().GetTy peCode(). 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.

      "John A Grandy" <johnagrandy-at-gmail-dot-comwrote in message
      news:OTzAWDdHJH A.4060@TK2MSFTN GP03.phx.gbl...
      Short of brute force , how to determine if a type is not a .net type ...
      e.g. a custom type, such as an enum ...
      >

      Comment

      • John A Grandy

        #4
        Re: determine if type is not .net type

        That's what I was afraid of.

        You'd think they'd build this in , it's such an obvious need.


        "Marc Gravell" <marc.gravell@g mail.comwrote in message
        news:c862f03e-b223-47c3-8fcc-a9cb34a56ac4@m4 5g2000hsb.googl egroups.com...
        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

        Comment

        • Peter Duniho

          #5
          Re: determine if type is not .net type

          On Mon, 29 Sep 2008 16:38:42 -0700, John A Grandy
          <johnagrandy-at-gmail-dot-comwrote:
          That's what I was afraid of.
          >
          You'd think they'd build this in , it's such an obvious need.
          How so? To nearly the last one, the vast majority of applications should
          never need this information.

          In what way is the need so obvious? What makes it such an important thing
          to be able to do that you're surprised it's not built-in?

          Pete

          Comment

          • Marc Gravell

            #6
            Re: determine if type is not .net type

            Indeed - actually, I like that fundamentally there is no distinction,
            and all types are (largely) equal citizens...

            Marc

            Comment

            Working...