Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. How to check if particular class is user defined?

How to check if particular class is user defined?

Scheduled Pinned Locked Moved C#
csharphelptutorialquestion
6 Posts 5 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    AksharRoop
    wrote on last edited by
    #1

    Hi All, I am writing an application in which I need to put check if a class is user defined or built in (C# or .Net). Can someone help me with this? Thanks, AksharRoop

    L D F S 4 Replies Last reply
    0
    • A AksharRoop

      Hi All, I am writing an application in which I need to put check if a class is user defined or built in (C# or .Net). Can someone help me with this? Thanks, AksharRoop

      L Offline
      L Offline
      Lost User
      wrote on last edited by
      #2

      This might not be the ideal solution, but you can get the namespace of a type. You could check whether the class part of the "System" or "Microsoft" namespaces :)

      I are Troll :suss:

      A 1 Reply Last reply
      0
      • L Lost User

        This might not be the ideal solution, but you can get the namespace of a type. You could check whether the class part of the "System" or "Microsoft" namespaces :)

        I are Troll :suss:

        A Offline
        A Offline
        AksharRoop
        wrote on last edited by
        #3

        Thanks but I need better solution if any .. :)

        1 Reply Last reply
        0
        • A AksharRoop

          Hi All, I am writing an application in which I need to put check if a class is user defined or built in (C# or .Net). Can someone help me with this? Thanks, AksharRoop

          D Offline
          D Offline
          Dave Kreskowiak
          wrote on last edited by
          #4

          There is no way to reliably tell. All classes in the .NET Framework are "user defined".

          A guide to posting questions on CodeProject[^]
          Dave Kreskowiak Microsoft MVP Visual Developer - Visual Basic
               2006, 2007, 2008
          But no longer in 2009...

          1 Reply Last reply
          0
          • A AksharRoop

            Hi All, I am writing an application in which I need to put check if a class is user defined or built in (C# or .Net). Can someone help me with this? Thanks, AksharRoop

            F Offline
            F Offline
            freakyit
            wrote on last edited by
            #5

            hi, if you write the classes you can use Attribute elements to determinate it.

            1 Reply Last reply
            0
            • A AksharRoop

              Hi All, I am writing an application in which I need to put check if a class is user defined or built in (C# or .Net). Can someone help me with this? Thanks, AksharRoop

              S Offline
              S Offline
              Sir Dot Net
              wrote on last edited by
              #6

              You could get the assembly attributes at runtime and check the publisher's name and or copyright notice for 'Microsoft'. Obviously this is not rock solid, but if you want that, the only verifiable way I can think of at the moment is to build a dictionary of all the .NET assemblies and their hash digests (See Assembly.Evidence), then verify the assembly against your dictionary. Not pretty.

              1 Reply Last reply
              0
              Reply
              • Reply as topic
              Log in to reply
              • Oldest to Newest
              • Newest to Oldest
              • Most Votes


              • Login

              • Don't have an account? Register

              • Login or register to search.
              • First post
                Last post
              0
              • Categories
              • Recent
              • Tags
              • Popular
              • World
              • Users
              • Groups