In MainWindow.xaml.cs
class, when trying to get access to my property Name
inside App.xaml.cs
class, I'm getting the error:
'App' does not contain a definition for 'Name'.
Why?
Remark: I'm working a scenario similar to this one. But author there is using a global variable, and as we know, in most cases, using properties is preferred over global variable. So, I'm trying property in my case.
App.xaml.cs:
public partial class App : Application
{
private string[] name;
public string[] Name
{
get { return name; }
set { name = value; }
}
}
MainWindow.xaml.cs:
public partial class MainWindow : Window
{
public MainWindow()
{
InitializeComponent();
string[] myArray = App.Name //VS2019 Intellisense gives the error: 'App' does not contain a definition for 'Name'
}
}