If I double click on a new winform button uxHelloButton then the following appears:
private void uxHelloButton_Click(object sender, RoutedEventArgs e)
Why is the default private?
If I delete private and leave the following it still works fine:
void uxHelloButton_Click(object sender, RoutedEventArgs e)
Does the addition of this scope avoid potential problems?
The question is: Why would you like to make it accessible?
In general, it’s better to give each element, the most restrictive permissions needed.
If you don’t, you are taking the risk that some classes can call this function where they shouldn’t.
Even from an OOP point of view, this must be private. This function is a callback used by the form to handle the button click. It is not meant to be called explicitly either by you or by any external class.
If you want to call this method, use the following instead:
Ps: The default scope in C# for an instance method is private, you did not expand it by removing the private keyword.