下面图片中的这种方法是什么?我如何制作这种方法?
我在网上搜索了很多,什么也没找到。尝试了很多东西,比如属性方法或属性方法,但都没有发现。
事实上,我的问题是我想让一个方法像这样工作,并且输入参数是可选的。
My Questions Image
以下是我的代码(面板除外,其他面板为枚举类型):
public static void Reset(System.Windows.Forms.Panel panel, formulaType formulaType, ShalvarType shalvarType = 0
, DamanType damanType = 0, YaqeType yaqeType = 0, BalataneType balataneType = 0, AstinType astinType = 0)
{
object[,] collcetion = null;
switch (formulaType)
{
case formulaType.Shalvar:
collcetion = shalvarFurmula(shalvarType);
break;
case formulaType.Daman:
collcetion = damanFurmula(damanType);
break;
case formulaType.Yaqe:
collcetion = yaqeFurmula(yaqeType);
break;
case formulaType.Balatane:
collcetion = balataneFurmula(balataneType);
break;
case formulaType.Astin:
collcetion = astinFurmula(astinType);
break;
}
//System.Windows.Forms.TextBox
for (int i = 0; i < collcetion.Length; i++)
{
if (panel.Controls[collcetion[i, 0].ToString()].GetType().ToString() == "System.Windows.Forms.TextBox")
{
panel.Controls[collcetion[i, 0].ToString()].Text = collcetion[i, 1].ToString();
}
else
{
System.Windows.Forms.NumericUpDown num = panel.Controls[collcetion[i, 0].ToString()] as System.Windows.Forms.NumericUpDown;
num.Value = Convert.ToDecimal(collcetion[i, 1]);
}
}
}
我想有面板和公式类型,但从第三个到最后都是这样。事实上,我给枚举类型的方式类似于图片。
顺便说一下,我发送的代码还不完整。
Thankx公司