private static void GetParam(Control c, ref string str)
{
try
{
foreach (Control ctl in c.Controls)
{
if (ctl is TextBox)
{
TextBox tx = ctl as TextBox;
str += tx.Name + "$" + tx.Text + "|";
}
else if (ctl is CheckBox)
{
CheckBox tx = ctl as CheckBox;
str += tx.Name + "$" + tx.Checked + "|";
}
else if (ctl is ComboBox)
{
ComboBox tx = ctl as ComboBox;
str += tx.Name + "$" + tx.Text + "|";
}
else if (ctl is NumericUpDown)
{
NumericUpDown tx = ctl as NumericUpDown;
str += tx.Name + "$" + tx.Value + "|";
}
if (ctl.Controls.Count > 0) GetParam(ctl, ref str);
}
}
catch (Exception)
{
}
}
界面只有兩個數值輸入控制元件,但是出來的str并不是我想要的字串

uj5u.com熱心網友回復:
在這句代碼 private static void GetParam(Control c, ref string str) 打上斷點然后使用單步除錯,盯著區域變數視窗你就知道怎么回事了如何給 VisualStudio 上的代碼添加斷點進行除錯請看 斷點除錯 Windows 源代碼
如何進行單步除錯和區域變數視窗在哪看請看 dotnet 代碼除錯方法
轉載請註明出處,本文鏈接:https://www.uj5u.com/net/66429.html
標籤:C#
