Hi Guys,
I am just giving a basic concept, think it in deep.
Let me proceed right away,
Let's assume the following classes,
public class A
{
public string PropA { get; set; }
public void MethodOfA()
{
Console.WriteLine("Calling MethodOfA from A");
}
public void MethodOfB()
{
Console.WriteLine("Calling MethodOfB from A");
}
}
public class B
{
public string PropA { get; set; }
public string PropB { get; set; }
public void MethodOfA()
{
Console.WriteLine("Calling MethodOfA from B");
}
}
public class C : A, B
{
}
Class C is derived from A and B classes
Now, class A and B both contains a common method MethodOfA() So, when I say
C c = new C();
c.MethodOfA();
It calls MethodOfA() from A and then it calls MethodOfA from B sequentially.And the output will be
Calling MethodOfA from A
Calling MethodOfA from B
Now, when I say
C c = new C();
c.A.MethodOfA();
It calls method of A only and same for B class.
And the output will be
Calling MethodOfA from A
So, I can call method in a row at one shot or I can call it by class name.
Same thing we can apply for the properties too.
We can set properties at one shot or we can get property at one shot.
We can set property by a class name or we can get property by a class name.