C# Object Initialization

using System;

 

namespace Application

{

public class Program

{

static void Main(string[] args)

{

BaseClass derivedObj = new DerivedClass();

derivedObj.ChangeGrade();

}

}

 

/// <summary>

/// Delcare a public parent class

/// </summary>

public class BaseClass

{

public BaseClass()

{

Console.WriteLine();

}

 

static BaseClass()

{

Console.WriteLine();

}

 

public virtual void ChangeGrade()

{

}

}

 

/// <summary>

/// Declare a public child class

/// </summary>

public class DerivedClass : BaseClass

{

public DerivedClass()

{

Console.WriteLine();

}

 

static DerivedClass()

{

Console.WriteLine();

}

 

public override void ChangeGrade()

{

base.ChangeGrade();

}

}

}

posted @ 2009-04-08 12:29  许晓光  阅读(122)  评论(0编辑  收藏  举报