->If both base and derived class contains same method names and variable names then we have to use
base keyword.
->Below sample code shows the use of base keyword.
Sample Code:-
{
int r=b.m();
Response.write(r);
}
}
public class A
{
public int X =10;
public string y="hello"
}
public class B:A
{
new public int x=20; // new keyword
new public string="rakesh"; // new keyword
public int m()
{
return x+base.X; // ussing base keyword(X is base class variable and x is derived class variable)
Note: We can access only same class variable and method(only base class member) but we can not access derive class variable and method
No comments:
Post a Comment