G
ggeshev
Hello!
I've got a method :
public static Object _Add(Object val1, Object val2); {}
val1 and val2 are among of these types :
- sbyte
- byte
- short
- ushort
- int
- uint
- long
- ulong
- float
- double
- decimal
Types of val1 and val2 do not necessarily match (i.e. val1 may be int and
val2 may be decimal).
The method should implement the Addition operation (val1 + val2) and return
the result in the propper type (i.e. if an integer and double are added,
result should be "double"; if sbyte and sbyte are added, the result should
be sbyte or short - if the resulting value is beyond sbyte limits).
What would be the implementation of this method look like?
Propose me some ideas for implementing the Addition operation and returning
the result in a propper type.
Thank you!
I've got a method :
public static Object _Add(Object val1, Object val2); {}
val1 and val2 are among of these types :
- sbyte
- byte
- short
- ushort
- int
- uint
- long
- ulong
- float
- double
- decimal
Types of val1 and val2 do not necessarily match (i.e. val1 may be int and
val2 may be decimal).
The method should implement the Addition operation (val1 + val2) and return
the result in the propper type (i.e. if an integer and double are added,
result should be "double"; if sbyte and sbyte are added, the result should
be sbyte or short - if the resulting value is beyond sbyte limits).
What would be the implementation of this method look like?
Propose me some ideas for implementing the Addition operation and returning
the result in a propper type.
Thank you!