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. check if a class is inherited from another class

check if a class is inherited from another class

Scheduled Pinned Locked Moved C#
question
5 Posts 3 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.
  • H Offline
    H Offline
    hpetriffer
    wrote on last edited by
    #1

    Is there a possibility (net 2.0) to check if a class is inherited from another class? I have no instances of the 2 classes only types. e.g. class A:class B { } class B:class C{ } class a inherits from class B? -> yes.... Regards Hansjörg Edit/Delete Message

    D G 2 Replies Last reply
    0
    • H hpetriffer

      Is there a possibility (net 2.0) to check if a class is inherited from another class? I have no instances of the 2 classes only types. e.g. class A:class B { } class B:class C{ } class a inherits from class B? -> yes.... Regards Hansjörg Edit/Delete Message

      D Offline
      D Offline
      Daniel Persson
      wrote on last edited by
      #2

      Have you tried: A aObj = new A(); if(aObj is B) //do something

      H 1 Reply Last reply
      0
      • D Daniel Persson

        Have you tried: A aObj = new A(); if(aObj is B) //do something

        H Offline
        H Offline
        hpetriffer
        wrote on last edited by
        #3

        is not possible because I don't have always the default constructor.... regards Hansjörg

        1 Reply Last reply
        0
        • H hpetriffer

          Is there a possibility (net 2.0) to check if a class is inherited from another class? I have no instances of the 2 classes only types. e.g. class A:class B { } class B:class C{ } class a inherits from class B? -> yes.... Regards Hansjörg Edit/Delete Message

          G Offline
          G Offline
          Guffa
          wrote on last edited by
          #4

          Use the IsSubclassOf method. --- b { font-weight: normal; }

          H 1 Reply Last reply
          0
          • G Guffa

            Use the IsSubclassOf method. --- b { font-weight: normal; }

            H Offline
            H Offline
            hpetriffer
            wrote on last edited by
            #5

            thanks this works

            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