c# - Why are form's tool events Private as a default? -


if double click on new winform button uxhellobutton following appears:

private void uxhellobutton_click(object sender, routedeventargs e) 

why default private? if delete private , leave following still works fine:

void uxhellobutton_click(object sender, routedeventargs e) 

does addition of scope avoid potential problems?

the question is: why make accessible? in general, it's better give each element, restrictive permissions needed. if don't, taking risk classes can call function shouldn't.

even oop point of view, must private. function callback used form handle button click. not meant called explicitly either or external class.

if want call method, use following instead:

private void uxhellobutton_click(object sender, routedeventargs e) {     somethingtodo(...); } protected void somethingtodo(...) {     .... } 

ps: default scope in c# instance method private, did not expand removing private keyword.


Comments

Popular posts from this blog

jquery - Invalid Assignment Left-Hand Side -

java - Play! framework 2.0: How to display multiple image? -

gmail - Is there any documentation for read-only access to the Google Contacts API? -