I have a generic class CGeometryCalibration2D<T>
which can be used with numeric types like int
, double
, float
, and my custom type CLocation
.
(less important) question 1: how can I restrict T to one of these types?
Inside this class, there is a function
double InterpolateReverse (T i_Value);
which should be used only with CLocation
as T
.
I don't know any way to apply such a restriction.
I already tried extension methods, which would do exactly this restriction
double InterpolateReverse (this CGeometricCalibration2D<CLocation>, CLocation i_Value);
but they don't allow access to private members. I could work around this limitation by using Reflection, but that's not the nicest way.
What can I do here?
Should I maybe find a completely different approach?
The only remaining idea I have is overloading the generic class by concrete implmentations and adding the function there, like
CGeometricCalibration2D_CLocation : CGeometricCalibration2D<CLocation>
{
double InterpolateReverse (CLocation i_Value);
}
but then I need to have an object of the concrete type CGeometricCalibration2D_CLocation
in order to execute InterpolateReverse ()