I'm following this tutorial, and at 16:16 it uses the following condition checking, which is a way to do it in C# 7.0 as far as I know.
if(Application.Current.MainWindow is MainWindow mainWindow)
{
mainWindow.Start_Btn.Ischecked = false;
}
My question here is how to do the same using C# 5.0.
I've tried stating a variable of the type before the if statement but with no results, and to be honest I don't have much idea of how to do it.
MainWindow mw;
if(Application.Current.MainWindow is mw)
{
mw.Start_Btn.Ischecked = false;
}
Edit: I have already checked the documentation (here and here), but it all refers to C# 7.0, and I'm trying to do it in 5.0 because some limitations I have at the moment.
Another edit: Same result can be obtained by
var window = (MainWindow)Application.Current.MainWindow;
window.Start_Btn.IsChecked = false;
window = null;
It doesn't check the type of Application.Current.MainWindow with a fancy declaration pattern inside an if statement, but it kind of works.