S
Sahil Malik
Okay, I can't inherit from System.ValueType. Why this restriction??
What I am trying to acheive is, create my own ValueType called "Money".
So if I have a decimal that has value 1.93991, when cast'ed to Money, it
gives me back "1.93", and I can easily write implicit and explicit casts to
do a to-and-fro conversion.
But I can't do such a conversion to-and-from from object, BECAUSE, my object
inherits from System.Object, and I have no other choice but to inherit from
System.Object #(@((# !)@()#_.
Is there an alternate way of acheiving this goal??
If you wanna see a code view, here is what I wanna do.
object o = 3.1991 ;
money m = (money)o ;
Console.WriteLine(m) ; // prints 3.19
alternatively,
money m = 1.29 ;
object o = m ;
decimal d = (decimal) o ;
Console.WriteLine(d) ; // prints 1.2900000 (well it won't print that but you
get the idea).
- Sahil Malik
http://dotnetjunkies.com/weblog/sahilmalik
What I am trying to acheive is, create my own ValueType called "Money".
So if I have a decimal that has value 1.93991, when cast'ed to Money, it
gives me back "1.93", and I can easily write implicit and explicit casts to
do a to-and-fro conversion.
But I can't do such a conversion to-and-from from object, BECAUSE, my object
inherits from System.Object, and I have no other choice but to inherit from
System.Object #(@((# !)@()#_.
Is there an alternate way of acheiving this goal??
If you wanna see a code view, here is what I wanna do.
object o = 3.1991 ;
money m = (money)o ;
Console.WriteLine(m) ; // prints 3.19
alternatively,
money m = 1.29 ;
object o = m ;
decimal d = (decimal) o ;
Console.WriteLine(d) ; // prints 1.2900000 (well it won't print that but you
get the idea).
- Sahil Malik
http://dotnetjunkies.com/weblog/sahilmalik