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. Why so many class in framework sealed?

Why so many class in framework sealed?

Scheduled Pinned Locked Moved C#
helpquestiongraphics
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.
  • L Offline
    L Offline
    Lost User
    wrote on last edited by
    #1

    I wanna expand the ability of some class provided by framework like Bitmap, but I find it modified by sealed. How can i do with it? Another similar problem is when i try to inherit XmlElement, I find its construction is modified by internal. Then the compiler find it as an error. any solution to bypass?

    G J A 3 Replies Last reply
    0
    • L Lost User

      I wanna expand the ability of some class provided by framework like Bitmap, but I find it modified by sealed. How can i do with it? Another similar problem is when i try to inherit XmlElement, I find its construction is modified by internal. Then the compiler find it as an error. any solution to bypass?

      G Offline
      G Offline
      Gerald Schwab
      wrote on last edited by
      #2

      I had the same problem with SqlDataReader. I just created a new class that wrapped each SqlDataReader method and property and then inherited from my class. It kind of sucks but I don't think there is any other way.

      L 1 Reply Last reply
      0
      • L Lost User

        I wanna expand the ability of some class provided by framework like Bitmap, but I find it modified by sealed. How can i do with it? Another similar problem is when i try to inherit XmlElement, I find its construction is modified by internal. Then the compiler find it as an error. any solution to bypass?

        J Offline
        J Offline
        James T Johnson
        wrote on last edited by
        #3

        Yes it stinks. The reason for Bitmap being sealed is because it is a wrapper around GDI+ which is a native DLL. .NET doesn't support inheritence from a native image, yet anyway :rolleyes: James Sonork: Hasaki "I left there in the morning with their God tucked underneath my arm their half-assed smiles and the book of rules. So I asked this God a question and by way of firm reply, He said - I'm not the kind you have to wind up on Sundays." "Wind Up" from Aqualung, Jethro Tull 1971

        1 Reply Last reply
        0
        • G Gerald Schwab

          I had the same problem with SqlDataReader. I just created a new class that wrapped each SqlDataReader method and property and then inherited from my class. It kind of sucks but I don't think there is any other way.

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

          Well, the wrapper is boring but i fininally made it. I think if Microsoft holds its position on sealing their class, then it will be a good idea to design a wizard to automatively build a wrapper. Hope C#'s reflection ability will make it possible. Do you think so?

          1 Reply Last reply
          0
          • L Lost User

            I wanna expand the ability of some class provided by framework like Bitmap, but I find it modified by sealed. How can i do with it? Another similar problem is when i try to inherit XmlElement, I find its construction is modified by internal. Then the compiler find it as an error. any solution to bypass?

            A Offline
            A Offline
            Andy Smith
            wrote on last edited by
            #5

            I can't speak for them all... but some are sealed for performance reasons. and I quote from "Applied Microsoft .NET Framework Programming": " the CLR knows the exact layout of the fields defined within the String type, and the CLR accesses these feilds directly." ... If String were not sealed, "you could add your own fields, which would break the assumptions the CLR makes, In addition, you could break some assumptions that the CLR has made about String objects being immutable."

            N 1 Reply Last reply
            0
            • A Andy Smith

              I can't speak for them all... but some are sealed for performance reasons. and I quote from "Applied Microsoft .NET Framework Programming": " the CLR knows the exact layout of the fields defined within the String type, and the CLR accesses these feilds directly." ... If String were not sealed, "you could add your own fields, which would break the assumptions the CLR makes, In addition, you could break some assumptions that the CLR has made about String objects being immutable."

              N Offline
              N Offline
              Nick Parker
              wrote on last edited by
              #6

              Andy Smith wrote: and I quote from "Applied Microsoft .NET Framework Programming": " the CLR knows the exact layout Here is Mircosoft "knowing" everything again... Nick Parker

              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