Shadowing??
-
Hi all, what is shawdoing? what is the difference b/w over loading & shadowing? i read this in mSDN but i am still confused with this concept. please can anyone explain me what is this Shadowing? Thanks in advance Rahi
If you look at what you do not have in life, you don't have anything, If you look at what you have in life, you have everything... "
-
Hi all, what is shawdoing? what is the difference b/w over loading & shadowing? i read this in mSDN but i am still confused with this concept. please can anyone explain me what is this Shadowing? Thanks in advance Rahi
If you look at what you do not have in life, you don't have anything, If you look at what you have in life, you have everything... "
By overloading a method you get an alternative for that method. By shadowing a method you simply hide the other version of the method and it becomes inaccessable.
WM. What about weapons of mass-construction? "You can always try to smash it with a wrench to fix that. It might actually work" - WillemM
-
Hi all, what is shawdoing? what is the difference b/w over loading & shadowing? i read this in mSDN but i am still confused with this concept. please can anyone explain me what is this Shadowing? Thanks in advance Rahi
If you look at what you do not have in life, you don't have anything, If you look at what you have in life, you have everything... "
Overloading can occur with in the same class too, for eg:
//Example for overloading public int addnumbers(int a, int b) { return a+b; } public int addnumbers(int a, int b, int c) { return a+b+c; }
Method Hiding can happen only when inheritance comes to picturepublic class Maths { public Maths() { //.Ctor } public int addnumbers(int a, int b) { return a+b; } } public class TwoMaths : Maths { public TwoMaths() { //.Ctor } // This method hides the base class's method // if you create a object for TwoMaths class, the base class's // addnumber method cannot be called unless until you explicitly //cast TwoMaths' object in to Maths object public int addnumbers(int a, int b) { return a+b; } }
-
By overloading a method you get an alternative for that method. By shadowing a method you simply hide the other version of the method and it becomes inaccessable.
WM. What about weapons of mass-construction? "You can always try to smash it with a wrench to fix that. It might actually work" - WillemM
Thanks now i got to know what Shadowing is. When ever i post some question in this forum by expecting this type of answers but i am not receiving exact response from the forum members. They are asking to read from the sites and books etc., they are correct. Atleast they are showing me the way but after reading from the book only i am posting my questions here. Some times i got struck (hang-up) with some topics may be they are very simple. as i am new to this technology..i need simple explaination like what u dropped here for shadowing.... Thanks once again for ur response. Rahi
If you look at what you do not have in life, you don't have anything, If you look at what you have in life, you have everything... "
-
Overloading can occur with in the same class too, for eg:
//Example for overloading public int addnumbers(int a, int b) { return a+b; } public int addnumbers(int a, int b, int c) { return a+b+c; }
Method Hiding can happen only when inheritance comes to picturepublic class Maths { public Maths() { //.Ctor } public int addnumbers(int a, int b) { return a+b; } } public class TwoMaths : Maths { public TwoMaths() { //.Ctor } // This method hides the base class's method // if you create a object for TwoMaths class, the base class's // addnumber method cannot be called unless until you explicitly //cast TwoMaths' object in to Maths object public int addnumbers(int a, int b) { return a+b; } }
thanks for ur response. really ur example is very simple and clear. this will be a very good example for those candidates(like me) who are new to this .net technology i came to know what shadowing is with ur's and willem's explanation. now i can read some more about shadowing from books & Sites. Thanks once again, Rahi
If you look at what you do not have in life, you don't have anything, If you look at what you have in life, you have everything... "