-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProgram.cs
More file actions
54 lines (46 loc) · 1.43 KB
/
Program.cs
File metadata and controls
54 lines (46 loc) · 1.43 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
using System;
using System.Collections;
using System.Reflection;
namespace ReflectionLab
{
class Program
{
static void Main(string[] args)
{
var type = typeof(ReflectionTest);
Console.WriteLine("命名空间名称:" + type.Namespace);
Console.WriteLine("直接基类型:" + type.BaseType);
Console.WriteLine("全名:" + type.FullName);
Console.WriteLine("是抽象类型:" + type.IsAbstract);
Console.WriteLine("是类:" + type.IsClass);
var type2 = typeof(IEnumerable);
Console.WriteLine("是接口:" + type2.IsInterface);
Console.WriteLine("直接基类型:" + type2.BaseType);
var members = type.GetMembers(BindingFlags.NonPublic | BindingFlags.Instance);
foreach (var m in members)
{
Console.WriteLine("【" + m.MemberType + "】:" + m.Name);
}
Console.ReadKey();
}
}
internal class ReflectionTest
{
//字段
static int a;
private int b;
protected int aa;
//属性
public double c { get; set; }
public static decimal d { get; set; }
//方法
ReflectionTest()
{
Console.WriteLine("调用构造函数");
}
public string AMethod()
{
return "返回一个字符串";
}
}
}