本文整理汇总了C#中Person.GetAge方法的典型用法代码示例。如果您正苦于以下问题:C# Person.GetAge方法的具体用法?C# Person.GetAge怎么用?C# Person.GetAge使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Person
的用法示例。
在下文中一共展示了Person.GetAge方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Classes_describe_real_world_objects
public void Classes_describe_real_world_objects()
{
Person person = new Person("brown", new DateTime(1984, 05, 04));
person.HairColor.ShouldBe(_);
person.GetAge().ShouldBe(_);
}
示例2: Main
static void Main(string[] args)
{
Person person1 = new Person();
person1.GatherPersonDetails();
Person.Count++;
System.Console.WriteLine("Person 1#:" + " " + person1.GetFullName() + "Person #1:" + " " + person1.GetAge() + "Person #1:" + person1.IsMarried());
if (person1.IsMarried() == true)
{
Person personspouse1 = new Person();
personspouse1.GetSpouseNameAndAge();
Person.Count++;
System.Console.WriteLine("Person 1#:" + " " + personspouse1.FirstName + " " + personspouse1.Age);
}
Person person2 = new Person();
person2.GatherPersonDetails();
Person.Count++;
System.Console.WriteLine("Person 2#:" + " " + person2.GetFullName() + "Person #2:" + " " + person2.GetAge() + "Person #2:" + person2.IsMarried());
if (person2.IsMarried() == true)
{
Person personspouse2 = new Person();
personspouse2.GetSpouseNameAndAge();
Person.Count++;
System.Console.WriteLine("Person 2#:" + " " + personspouse2.FirstName + " " + personspouse2.Age);
}
Person person3 = new Person();
person3.GatherPersonDetails();
Person.Count++;
System.Console.WriteLine("Person 3#:" + " " + person3.GetFullName() + "Person #3:" + " " + person3.GetAge() + "Person #3:" + person3.IsMarried());
if (person3.IsMarried() == true)
{
Person personspouse3 = new Person();
personspouse3.GetSpouseNameAndAge();
Person.Count++;
System.Console.WriteLine("Person 3#:" + " " + personspouse3.FirstName + " " + personspouse3.Age);
}
double.Parse(System.Console.WriteLine("Average Age:" + GetAverageAge()));
}