❔ Why is PointF not simply Point<float>?
Why isn't there simply a generic
Point
class that allows for Point<int
, Point<float
, Point<decimal>
, ...?
Is it for historical or performance reasons?5 Replies
this would only be possible in .net 7 and up
and since that only came out last year, yeah, it's for historical reasons
Why is that?
because you need to constrain the generic parameter to something that is a number
and .net 7 introduced generic math with
INumber<T>
so you could technically have struct Point<TNumber> where TNumber : INumber<TNumber>
ah okay, thanks
Looks like nothing has happened here. I will mark this as stale and this post will be archived until there is new activity.