Does C# have Type Wrappers?

  • Thread starter Thread starter John Smith
  • Start date Start date
John Smith said:
Is it possible to create Type Wrappers in C#? If so, how do you do it?

For those not sure of what I mean, here's a quick link on Type Wrappers in
Java: http://home.cogeco.ca/~ve3ll/jatutor5.htm#tw

There's no need, due to boxing. However, your page has:

"Simple datatypes are passed by value and not by reference."

That suggests that you think reference type parameters in Java are
passed by reference - they're not, the reference is passed by value.
There's a difference between reference passed by value and value passed
by reference.

See http://www.pobox.com/~skeet/java/passing.html for more information.
 
Type wrapping is not needed in C# because the language will create an object
and place a value type into it when it is needed. This is called "boxing".
The inverse is to unwrap the value type from the object, which is called
"unboxing." The gyrations caused by Java's decision not to derive the base
types from the type "object" is simply not present in C#

Hope this helps,
--- Nick
 
Back
Top