有什么方法可以重构此代码,而不必使用临时变量,而仍然使用与对象初始化程序关联的语法糖?
FrmSomeForm someTempForm = new FrmSomeForm()
{
SomePropA = "A",
SomePropB = "B",
SomePropC = "C"
};
using (FrmSomeForm someForm = someTempForm)
{
someForm.ShowDialog();
}
最佳答案
using (FrmSomeForm someForm = new FrmSomeForm(){
SomePropA = "A",
SomePropB = "B",
SomePropC = "C"
})
{
someForm.ShowDialog();
}
这不行吗? O