日期:2014-05-18 浏览次数:21081 次
using System;
using System.Collections.Generic;
using System.Text;
using System.Reflection;
namespace ReflectionTest
{
class Program
{
static void Main(string[] args)
{
xx.xxx("ReflectionTest.a");
show();
Console.WriteLine("-----");
xx.xxx("ReflectionTest.b");
show();
Console.ReadLine();
}
private static void show()
{
foreach (string x in xx.c)
{
Console.WriteLine(x);
}
}
}
public class a
{
public static string[] ss = new string[] { "0", "1", "2" };
}
public class b
{
public static string[] ss = new string[] { "3", "4", "5", "6", "7" };
}
public class xx
{
public static string[] c;
public static void xxx(string xxxx)
{
FieldInfo t = Assembly.Load("ReflectionTest").GetType(xxxx).GetField("ss");
c = (string[])t.GetValue(null);
}
}
}