Override
Written by: maffelu , 2009-04-17 07:20:57
public virtual void Description()
{
Console.WriteLine("Weight: {0}", Weight);
Console.WriteLine("Owner: {0}", Owner);
}
public void Description()
{
Console.WriteLine("Weight: {0}", Weight);
Console.WriteLine("Owner: {0}", Owner);
Console.WriteLine("Brand: {0}", Brand);
Console.WriteLine("Years since last service: {0}", YearsSinceLastService);
}
public override void Description()
{
base.Description();
Console.WriteLine("Brand: {0}", Brand);
Console.WriteLine("Years since last service: {0}", YearsSinceLastService);
}
public sealed override void Description()
using System;
namespace TestApp
{
public class Vehicle
{
private int weight;
private string owner;
public int Weight
{
get{return weight;}
set{weight = value;}
}
public string Owner
{
get{return owner;}
set{owner = value;}
}
public virtual void Description()
{
Console.WriteLine("Weight: {0}", Weight);
Console.WriteLine("Owner: {0}", Owner);
}
}
}
using System;
namespace TestApp
{
public class Car : Vehicle
{
private string brand;
private int yearsSinceLastService;
public string Brand
{
get{return brand;}
set{brand = value;}
}
public int YearsSinceLastService
{
get{return yearsSinceLastService;}
set{yearsSinceLastService = value;}
}
public sealed override void Description()
{
base.Description();
Console.WriteLine("Brand: {0}", Brand);
Console.WriteLine("Years since last service: {0}", YearsSinceLastService);
}
}
}
using System;
namespace TestApp
{
class Program
{
public static void Main(string[] args)
{
Car car = new Car();
car.Weight = 1000;
car.Owner = "Joe Cuhp";
car.Brand = "Volvo";
car.YearsSinceLastService = 5;
car.Description();
Console.Read();
}
}
}
There are no comments on this article.
If you have any question or just want to leave a message, just fill out the form below!
Your e-mail will not be visible in your post, it is for validation reasons only
Maffelu
Creator and admin of MorkaLork.com.
Started programming in HTML back when frames and tables was the way to design a page, moved on to Pascal/Delphi, PHP, javascript/jQuery, VB.NET/C#, Java and C++.
Currently studies .NET (in general) focusing on ASP.NET.