第七次作业
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Reflection;
using System.Diagnostics;
namespace ConsoleApplication9
{}
class Program
{
Book book;
FootBall football;
static void Main(string[] args)
{
FieldInfo[] fi = typeof(Program).GetFields(BindingFlags.NonPublic | BindingFlags.Instance);
for (int i = 0; i < fi.Length; i++)
{
object[] obj = fi[i].FieldType.GetCustomAttributes(typeof(PlayAttribute), false);
if (obj != null && obj.Length > 0)
{
Console.WriteLine("Name:{0} Type:{1}", fi[i].Name, fi[i].FieldType);
}
}
Console.Read();
}
}
public class PlayAttribute : Attribute
{
}
[Play]
public class Book { }
public class FootBall { }