Extend UInt16 Object? Possible?

Mark Wills

Member
Joined
Jul 11, 2004
Messages
13
Location
Worldwide
Programming Experience
10+
Hello,

I would like to add a new method to the UInt16 object: .ToHex

Is it possible? How is it done if it is possible?

I can get the behaviour I want, no problem, using Hex(value) but I thought it would be nice to extend to the object and give it a ToHex function... Not sure how to go about it though...

Any pointers greatly appreciated

Thanks

Mark
 
It already has hex conversion through ToString("X") method.
 
Thanks

Thank you. I didn't know that! I just searched my MSDN for ToString("X") - came up with nothing! :-/

Mark.
 
well, it's kind of a secret... no, just kidding :) There are 4 overloads of ToString method, one of them as mentioned take a string parameter to specify formatting. If you look up ToString documentation there is a link to "Formatting overview", this one is listed in "standard numeric format strings".
 
Back
Top