C
C#2y ago
wertzui123

❔ 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
ero
ero2y ago
this would only be possible in .net 7 and up and since that only came out last year, yeah, it's for historical reasons
wertzui123
wertzui123OP2y ago
Why is that?
ero
ero2y ago
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>
wertzui123
wertzui123OP2y ago
ah okay, thanks
Accord
Accord2y ago
Looks like nothing has happened here. I will mark this as stale and this post will be archived until there is new activity.
Want results from more Discord servers?
Add your server