Assuming I have the following code:
public static Dictionary<string, ViewModelBase> LoadDictionary()
{
Dictionary<string, ViewModelBase> tempDictionary = new Dictionary<string, ViewModelBase>();
tempDictionary.Add("LoginView", new LoginViewModel());
tempDictionary.Add("SignUpView", new SignUpViewModel());
tempDictionary.Add("ContactListView", new ContactListViewModel());
return tempDictionary;
}
I refer to this line:
Dictionary<string, ViewModelBase> tempDictionary = new Dictionary<string, ViewModelBase>();
Does the compiler first create a constructor (parameterless ctor) and only then add my KeyValuePairs?
If so, how will my parameter ctor would look like (of the LoadDictionary)?
And the most important question relevant to this post is:
When I add my KeyValuePairs, are the Values also instantiated or do they wait to called and then are instantiated?
I mean to:
new LoginViewModel()
new SignUpViewModel()
new ContactListViewModel()
EDIT:
I Simply want to know if
tempDictionary.Add("LoginView", new LoginViewModel());
would be executed and call the LoginViewModel constructor even if I did not call the "LoginView" key in any other part of my program.