What are the benefits to defining methods as protected
in C#?
like :
protected void KeyDemo_KeyPress( object sender, KeyPressEventArgs e )
{
// some code
}
As compared to something like this:
private void FormName_Click( object sender, EventArgs e )
{
//some code
}
I've seen such examples in many books and I don't understand why and when do they use private
vs protected
?
Protected methods can be called from derived classes. Private methods can't.
That's the one and only difference between private and protected methods.