what is the difference between overloading and overriding?
and what is the advantage of overriding?
thanks
Overloading allows you to create the same method with different arguments:
private void someMethod(string arg) {}
private void someMethod(int arg) {}
Overriding allows you to change a method completely as long as you keep the same argument list.
Base class:
public virtual int someMethod(int arg)
{
return arg + arg;
}
Inherited class:
public override int someMethod(int arg)
{
return arg * arg;
}
The main advantage of overriding is that the base class architect can completely design and test his class and any developer can then change the functionality of the class to the limitations that the architect allows.
NC...
this is a good answer as well!!
http://www.dotnetspider.com/qa/Question36.aspx
That's good too Fadil. I just tried to make it as simple as possible.
NC...
yes NC01!!
you are right... but i gave him this link where it has the same answer roughly but with other feedback from different people ... your answer is absolutely ideal but you know sometimes you prefer to read read more that one resource so i hope you did not misunderstand me
Not at all Fadil!
NC...
0 comments:
Post a Comment