how does wrapper class works?
-
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.
-
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.
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 -
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.
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 )
-
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 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/