我相信这是一个非常简单的问题。谁能解释为什么这段代码输出 1000,而不是 1050
public class Program
{
public static void Main()
{
Bus b = new Bus(1000);
((Car)b).IncreaseVolume(50);
Console.WriteLine(b.GetVolume());
}
}
public interface Car
{
int GetVolume();
void IncreaseVolume(int amount);
}
public struct Bus : Car
{
private int volume;
public Bus(int volume)
{
this.volume = volume;
}
public int GetVolume()
{
return volume;
}
public void IncreaseVolume(int amount)
{
volume += amount;
}
}
}