class1.cs

来自「C#开发教程 由浅入深 配有实例 是初学者的好帮手」· CS 代码 · 共 48 行

CS
48
字号
using System;
using System.Reflection;

public class Apple 
{
	public int nSeeds;
	public void Ripen() 
	{
	}
}

public class TypeOfApp
{
	[STAThread]
	static void Main(string[] args)
	{
		// Retrieve the System.Type object from the class definition.
		Type t = typeof(Apple);
		string className = t.ToString();

		Console.WriteLine("\nInformation on the class {0}", 
			className);
	    
		Console.WriteLine("\n{0} methods", className);
		Console.WriteLine("-----------------------------");
		MethodInfo[] methods = t.GetMethods();
		foreach (MethodInfo method in methods) 
		{
			Console.WriteLine(method.ToString());
		}

		Console.WriteLine("\nAll {0} members", className);
		Console.WriteLine("-----------------------------");
		MemberInfo[] allMembers = t.GetMembers();
		foreach (MemberInfo member in allMembers) 
		{
			Console.WriteLine(member.ToString());
		}      

		// Retrieve the System.Type object from the object.
		Apple apple = new Apple();
		Type t2 = apple.GetType();   
	}
}



⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?