Explicit call of abstract static interface member (Preview feature) #5027
Answered
by
giladfrid009
giladfrid009
asked this question in
Q&A
-
The lasest VS 2022 and .NET 6 provides access to preview language features such as abstract static interface member and generic numeric types. I can't figure out how to call an explicit implementation of abstract interface member. double ToDouble<T>(T val) where T : INumber<T>
{
return double.Create(val); // does not compile. double implements INumber<T>.Create explicitly, how do I call it?
}
TRes Convert<T, TRes>(T val) where T : INumber<T>, where TRes : INumber<T>
{
return TRes.Create(val); // compiles just fine, can provide double as TRes, and will act the same as the previous function.
} How can I implement |
Beta Was this translation helpful? Give feedback.
Answered by
giladfrid009
Aug 11, 2021
Replies: 1 comment 1 reply
-
Apparently, invoking explicit static abstract method directly is not possible, so must use the Convert func. |
Beta Was this translation helpful? Give feedback.
1 reply
Answer selected by
giladfrid009
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Apparently, invoking explicit static abstract method directly is not possible, so must use the Convert func.