Value types ( struct) are passed by value, but interfaces are considered reference types (not value types). Let's get a look:
Bus b = new Bus(1000);
Now bcontains the value of a Buswith its volume equal to 1000.
Car c = (Car)b;
b ( ) Car. c .
c.IncreaseVolume(50);
IncreaseVolume, Car. . ( ).
void Car.IncreaseVolume(int amount)
{
((Bus)this).IncreaseVolume(amount);
}
:
public void IncreaseVolume(int amount)
{
volume += amount;
}
. , b, . , 1000:
Console.WriteLine(b.GetVolume());
.