我将一个绑定enum
到这样的属性网格:
public enum myEnum
{
Ethernet,
Wireless,
Bluetooth
}
public class MyClass
{
public MyClass()
{
MyProperty = MyEnum.Wireless;
}
[DefaultValue(MyEnum.Wireless)]
public MyEnum MyProperty { get; set; }
}
public Form1()
{
InitializeComponent();
PropertyGrid pg = new PropertyGrid();
pg.SelectedObject = new MyClass();
pg.Dock = DockStyle.Fill;
this.Controls.Add(pg);
}
我的问题:我在程序运行时即时获取数据。我阅读了网络适配器,然后将适配器名称存储为myArray
:
string[] myArray = new string[] { };
myArray[0] = "Ethernet";
myArray[1] = "Wireless";
myArray[2] = "Bluetooth";
是否可以使用 c# 即时转换myArray
为?myEnum
谢谢你。