My function returns some long value which contains two values in lower and higher 32 bits.
I thought the best ways to handle return value is to derive my custom type from long and provide type extenders like GetLowerValue(), GetHigherValue().
The problem is that .NET does not allow to derive from long
If you compile that
public class SubmitOrderResult : long
{
}
you get:
cannot derive from sealed type 'long'
Why is that designed so and how can overcome it?
Thanks
As already mentioned value types in .NET are sealed so there is no way you can derive from long. You should create extension methods as suggested.
Example
public static class LongExtensions
{
public static long GetLowerValue(this long value)
{
...
}
public static long GetHigherValue(this long value)
{
...
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With