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 does wrapper class works?

how does wrapper class works?

Scheduled Pinned Locked Moved C#
questiontutorial
4 Posts 4 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.
  • C Offline
    C Offline
    cyn8
    wrote on last edited by
    #1

    Hi, can anyone explain with example(if can) what is a wrapper class? From my basic understanding, u can use it in order to enable reusability and also if in case in the future, there is a better class, u can just replace it with the new one. However, i'm not quite sure how it works. Thanks for any reply.

    C C I 3 Replies Last reply
    0
    • C cyn8

      Hi, can anyone explain with example(if can) what is a wrapper class? From my basic understanding, u can use it in order to enable reusability and also if in case in the future, there is a better class, u can just replace it with the new one. However, i'm not quite sure how it works. Thanks for any reply.

      C Offline
      C Offline
      Chaitanya Joshi
      wrote on last edited by
      #2

      Wrapper class is an avtivity of migrating non OO types in languages in OO types i.e. in case of C# from basic value types (excepting structs, enums) to class types. If this is somewhat difficult to consume consider following example. Say you have one 'int' value which you want to wrap. So you would write a class like: public class Integer { private int var; public Integer(int v) { this.var = v; } public get(){...} public set(){...} } So now you have wrapped a simple integer into a class Integer which will be an OO type. Fortunately they are directly available in C# libraries. Now a millon dollar question. What is use of this?? See, when you are going to deal with something which requires complete OO types e.g. object serialization, remoting you need this concept. As the complete manifest information is required in order to perform the activity. That is it. Chaitanya Joshi

      1 Reply Last reply
      0
      • C cyn8

        Hi, can anyone explain with example(if can) what is a wrapper class? From my basic understanding, u can use it in order to enable reusability and also if in case in the future, there is a better class, u can just replace it with the new one. However, i'm not quite sure how it works. Thanks for any reply.

        C Offline
        C Offline
        Christian Graus
        wrote on last edited by
        #3

        No, a wrapper class is typically a class that exists solely to import and expose functionality that is otherwise not available. For example, my article on using the Canon SDK in C# is a wrapper class, the class exposes methods which call the methods in the Canon SDK dlls, via p/invoke. My classes are a wrapper, I do not offer Canon camera connection, simply a way to call a C++ SDK from C#.

        Christian Graus - Microsoft MVP - C++ "I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )

        1 Reply Last reply
        0
        • C cyn8

          Hi, can anyone explain with example(if can) what is a wrapper class? From my basic understanding, u can use it in order to enable reusability and also if in case in the future, there is a better class, u can just replace it with the new one. However, i'm not quite sure how it works. Thanks for any reply.

          I Offline
          I Offline
          il_masacratore
          wrote on last edited by
          #4

          I try to explain you my view, A wrapper class enables reusability because you add an "interface" beetween implementation code and the use of it. If it's well designed, you can change implementation and its impact on use is minimal. If not, you will have to do a lot of changes in use code.

          Visit my blog at http://dotnetforeveryone.blogspot.com/

          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