您的位置:首页 > 编程语言 > C#

白话C#:特性(转)

2015-07-02 15:59 841 查看
static void Main(string[] args)
{
BoardingCheckAttribute boardingCheck = null;
object[] customAttributes = typeof(HumanPropertyBase).GetCustomAttributes(true);

foreach (var attribute in customAttributes)
{
if (attribute is BoardingCheckAttribute)
{
boardingCheck = attribute as BoardingCheckAttribute;

Console.WriteLine(boardingCheck.Name
+ ""s ID is "
+ boardingCheck.ID
+ ", he/she wants to "
+ boardingCheck.Destination
+ " from "
+ boardingCheck.Departure
+ " by the plane "
+ boardingCheck.FlightNumber
+ ", his/her position is "
+ boardingCheck.PositionNumber
+ ".");
}
}

Console.ReadLine();
}


View Code
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: