26.10.txt

来自「《Microsoft Visual C# .NET 2003开发技巧大全》源代码」· 文本 代码 · 共 23 行

TXT
23
字号
Listing 26.10 Enumerating Device Properties
private void DeviceInformationForm_Load(object sender, System.EventArgs e)
{
if( !Page.IsPostBack )
{
StringBuilder sb = new StringBuilder();
// for each public property
foreach( PropertyInfo prop in
Device.GetType().GetProperties(
BindingFlags.Instance | BindingFlags.Public) )
{
// only retrieve boolean properties
if( prop.PropertyType != typeof(bool))
continue;
// print out property name and current value
if( prop.GetValue(Device, null) != null )
tvDeviceInfo.Text += “<b>” +
prop.Name + “</b> = <em>” +
prop.GetValue( Device, null ).ToString()+ “</em><br>”;
}
}
}

⌨️ 快捷键说明

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