using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using System.Reflection;
namespace SilverlightApplication20
{
public partial class MainPage : UserControl
{
public MainPage()
{
InitializeComponent();
this.Loaded += new RoutedEventHandler(MainPage_Loaded);
}
void MainPage_Loaded(object sender, RoutedEventArgs e)
{
//Silverlight4.0使用反射来遍历枚举
Type enumType = typeof(Days);
FieldInfo[] infos;
infos = enumType.GetFields(BindingFlags.Public | BindingFlags.Static);
foreach (FieldInfo fi in infos)
{
MessageBox.Show(fi.Name);
}
}
enum Days
{
Saturday,
Sunday,
Monday,
Tuesday,
Wednesday,
Thursday,
Friday
}
}
}
Silverlight4.0使用反射来遍历枚举
最新推荐文章于 2022-11-13 20:02:38 发布