这是因为第二种写法生成的代码差不多是这样:var form2 = new Form();
form2.Location = new Point(100, 100);
using (var form = form2)
{
form.ShowDialog();
}
它报的是这个临时的form2在丢失范围之前没有释放。实际上form和form2是一个东西,而且那样写这个临时的form2在using之外也没法直接使用,所以这个警告可以忽略。
form2.Location = new Point(100, 100);
using (var form = form2)
{
form.ShowDialog();
}
它报的是这个临时的form2在丢失范围之前没有释放。实际上form和form2是一个东西,而且那样写这个临时的form2在using之外也没法直接使用,所以这个警告可以忽略。
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货