热烈祝贺Beijing第29界奥运会,隆重开幕,登世界的台,唱中国的戏!

事要一件一件的做...

态度决定一切,只要自己做了,无论结果怎样.

博客园 首页 新随笔 联系 订阅 管理
  58 Posts :: 0 Stories :: 12 Comments :: 0 Trackbacks

using System;

public class Person
{
 public string name = "";
 public int age = 0;

 //默认构造函数
 public Person()
 {
 }

 //构造函数重载(1)
 public Person(int Age)
 {
  this.age = Age;
 }

 //构造函数重载(2)
 public Person(int Age, string Name)
 {
  this.age = Age;
  this.name = Name;
 }

 public void ShowInfo()
 {
  Console.WriteLine("The name is : " + name);
  Console.WriteLine("The age is:" + age);
 }
}

class Client
{
 public static void Main()
 {
  Person p1 = new Person();
  p1.ShowInfo();

  Console.WriteLine("==========================");

  Person p2 = new Person(30);
  p2.ShowInfo();

  Console.WriteLine("==========================");
  Person p3 = new Person(30, "Tom");
  p3.ShowInfo();
 }
}

posted on 2008-08-04 18:02 fay 阅读(17) 评论(0)  编辑 收藏 网摘 所属分类: C# 面向对象程序设计

标题  
姓名  
主页
Email (博主才能看到) 
验证码 *  看不清,换一张 [登录][注册]
内容(请不要发表任何与政治相关的内容)  
  登录  使用高级评论  新用户注册  返回页首  恢复上次提交      
Google站内搜索

相关文章:

相关链接:


 

风行 网络电影 边下边看