c#学习笔记二:构造函数执行顺序

/*
 * Created by SharpDevelop.
 * User: Administrator
 * Date: 2013-3-24
 * Time: 20:29
 * 
 * To change this template use Tools | Options | Coding | Edit Standard Headers.
 */
using System;

namespace construct
{
	class Car
	{
		private string name;
		private int luen;
		
		public Car(string name, int luen)
		{
			Console.WriteLine("two param");
			this.name = name;
			this.luen = luen;
			Console.WriteLine(this.name);
			Console.WriteLine(this.luen);
			
		}
		
		public Car(string name):this(name, 4)
		{
			Console.WriteLine("one param");
		}
	}
	
	class Program
	{
		public static void Main(string[] args)
		{
			Car car = new Car("Leon Car!");
			
			Console.Write("Press any key to continue . . . ");
			Console.ReadKey(true);
		}
	}
}

  

posted @ 2013-03-24 20:38  践道者  阅读(208)  评论(0编辑  收藏  举报