New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Cast to var #2827
Comments
This looks like For upcasting, it's recommended to use a helper method T StaticCast<T, TDerived>(TDerived o) where TDerived : T => o; But now you need to specify all type arguments. While partial type inference (#1349) could help with that, you could hide static class StaticCast<T> {
static T From<TDerived>(TDerived o) where TDerived : T => o;
} But once we have type inference from target-type (#92) you could use the original method with all type arguments inferred: x = Cast(y); // Cast<int, object>(y) which will work for upcasting as well. |
Why not write it even shorter: x = ()y; for target-typed explicit cast. |
x = y; ? What is this, VB? ;)
…On Fri, Sep 27, 2019, 9:08 AM setbbtjl8wwq ***@***.***> wrote:
@ronnygunawan <https://github.com/ronnygunawan> or even ;)
x = y;
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<#2827?email_source=notifications&email_token=AAT52GQAQ3BXNSU5E6DFBCLQLYATLA5CNFSM4I23J7T2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOD7Y2UVI#issuecomment-535931477>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AAT52GQKUBKY7TKK5PKEW3TQLYATLANCNFSM4I23J7TQ>
.
|
|
This would be a shortcut for casting to the type of a variable - for instance
the cast would be equivalent to
(int)y
becausex
is of typeint
.The text was updated successfully, but these errors were encountered: