本文整理汇总了C#中Car.DisplayDetails方法的典型用法代码示例。如果您正苦于以下问题:C# Car.DisplayDetails方法的具体用法?C# Car.DisplayDetails怎么用?C# Car.DisplayDetails使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Car
的用法示例。
在下文中一共展示了Car.DisplayDetails方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ClassExamples1Func
public static void ClassExamples1Func()
{
Car car1 = new Car();
car1.m_Name = "MX5";
car1.m_nDoors = 2;
car1.m_Motor.m_nPowerBHP = 140;
Car car2 = new Car();
car2.m_Name = "9-3";
car2.m_Manufacturer = "Saab";
car2.m_nDoors = 4;
car2.m_Motor.m_nPowerBHP = 150;
Bike bike = new Bike();
bike.m_Name = "GSX-R750";
bike.m_Manufacturer = "Suzuki";
bike.m_Motor.m_nPowerBHP = 120;
car1.DisplayDetails();
car2.DisplayDetails();
Car.DisplayStaticDetails();
// Default arguments...
bike.Colour("Red");
bike.Colour("White", "Blue");
bike.DisplayDetails();
// Out parameters...
int nKW;
bike.m_Motor.UpdatePowerBHP(160, out nKW);
// ref parameters...
int nBHP=0;
nKW=0;
bike.m_Motor.UpdateCylinders(4, ref nBHP, ref nKW);
// Object initializer
Motor TestMotor = new Motor
{
m_nCylinders= 6,
m_nPowerBHP= 320,
// m_nPowerKW= 0
};
// Is and as conversions
Vehicle transportation = new Car();
if (transportation is Car)
transportation.m_BaseColour = "red";
if (transportation is Bike)
transportation.m_BaseColour = "blue";
Console.WriteLine("transportation is {0}", transportation.m_BaseColour);
Bike mybike = transportation as Bike;
if (mybike != null)
{
mybike.m_Manufacturer = "yamaha";
}
Car mycar = transportation as Car;
if (mycar != null)
{
mycar.m_Manufacturer = "ford";
}
}