C# 错误无法在此范围内声明局部变量
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/16263099/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-10 00:34:44 来源:igfitidea点击:
Error A local variable cannot be declared in this scope
提问by Orangelight
I am trying to unzip a file with DotNetZip but I get a error on the "e"
我正在尝试使用 DotNetZip 解压缩文件,但在“e”上出现错误
using (ZipFile zip = ZipFile.Read(openFileDialog1.FileName))
{
foreach (ZipEntry e in zip)
{
e.Extract(Environment.CurrentDirectory, ExtractExistingFileAction.OverwriteSilently);
}
}
采纳答案by Matthew Watson
I suspect you are doing this inside an event handler which already has a parameter called e.
我怀疑你是在一个已经有一个名为e.
Try renaming eto entryinside the foreach.
尝试重命名e到entry里面foreach。

