Here's the code I'm working with, the only change I've made there is added [CallerMemberName]
attribute in void Changed([CallerMemberName] string name = "")
method like that. In an article yesterday, I've read that instead of doing
public event EventHandler CanExecuteChanged
{
add { CommandManager.RequerySuggested += value; }
remove { CommandManager.RequerySuggested -= value; }
}
I could replace this part:
{
add { CommandManager.RequerySuggested += value; }
remove { CommandManager.RequerySuggested -= value; }
}
with a ;
and add a function to handle CanExecuteChanged
in Command
class like this:
public void Evaluate() => CanExecuteChanged?.Invoke(null, EventArgs.Empty);
and call the Evaluate
method inside the setters
of FirstName
and LastName
properties of Person
class. I've tested the app with both add/remove
and Evaluate
and both works.
Which of these would be more efficient?