- 积分
- 40165
- 好友
- 记录
- 主题
- 帖子
- 听众
- 收听
|
发表于 2013-3-26 11:19:55
|
显示全部楼层
我这里有个你参考下
[code=csharp]using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ConsoleApplication1
{
/// <summary>
/// 老师类 教工号,姓名,生日,职称,参加工作时间等属性
/// </summary>
public class Teacher
{
#region 属性
/// <summary>
/// 教工号
/// </summary>
public int ID { get; set; }
/// <summary>
/// 姓名
/// </summary>
public string Name { get; set; }
/// <summary>
/// 生日
/// </summary>
public string Birthday { get; set; }
/// <summary>
/// 职称
/// </summary>
public string TechnicalTitle { get; set; }
/// <summary>
/// 工作时间
/// </summary>
public string WorkHours { get; set; }
#endregion
#region 构造器
/// <summary>
/// 给老师类ID赋值
/// </summary>
/// <param name="id">教工号</param>
public Teacher(int id)
{
ID = id;
}
/// <summary>
/// 给老师类姓名和生日赋值
/// </summary>
/// <param name="name">老师姓名</param>
/// <param name="birthday">老师生日</param>
public Teacher(string name)
{
Name = name;
}
/// <summary>
/// 给老师类职称和工作时间赋值
/// </summary>
/// <param name="technicalTitle"></param>
/// <param name="workhours"></param>
public Teacher(string birthday, string technicalTitle, string workhours)
{
Birthday = birthday;
TechnicalTitle = technicalTitle;
WorkHours = workhours;
}
#endregion
#region 程序入口
/// <summary>
/// 应用程序的主入口点。
/// </summary>
public static void Main()
{
Console.WriteLine("------------------老师教号--------------------\r\n");
Teacher t = new Teacher(1001);
Console.WriteLine("教号:" + t.ID);
Console.WriteLine("------------------老师姓名--------------------\r\n");
t = new Teacher("苏飞");
Console.WriteLine("姓名:" + t.Name);
Console.WriteLine("------------------老师生日,职称,工作时间--------------------\r\n");
t = new Teacher("21985-10-13", "副教授", "2006-06-09");
Console.WriteLine("生日:" + t.Birthday + "\t职称:" + t.TechnicalTitle + "\t工作时间:" + t.WorkHours);
}
#endregion
}
}
[/code]
效果如下
|
|