person.cs
来自「this is a good book for the visual c#」· CS 代码 · 共 42 行
CS
42 行
// Fig. 10.16: Person.cs
// Class Person has a birthday.
using System;
public class Person : IAge
{
private string firstName;
private string lastName;
private int yearBorn;
// constructor
public Person( string firstNameValue, string lastNameValue,
int yearBornValue )
{
firstName = firstNameValue;
lastName = lastNameValue;
if ( yearBornValue > 0 && yearBornValue <= DateTime.Now.Year )
yearBorn = yearBornValue;
else
yearBorn = DateTime.Now.Year;
}
// property Age implementation of interface IAge
public int Age
{
get
{
return DateTime.Now.Year - yearBorn;
}
}
// property Name implementation of interface IAge
public string Name
{
get
{
return firstName + " " + lastName;
}
}
} // end class Person
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?