一部のVBをC#に変換しようとしています...(C#も学習しています)。ディレクトリ内のファイルをループしてファイル情報を取得するコードがいくつかあります。私はこれを元々VBに持っていますが、C#を学習しようとしていますが、オンラインコンバーターは.net2.0を渡すコードを提供しません。
エラーは次のとおりです。
Type and identifier are both required in a foreach statement
これが私が持っているコードです:
DirectoryInfo dirInfo = new DirectoryInfo(currentDir);
FileInfo[] files = null;
files = dirInfo.GetFiles();
FileInfo f = default(FileInfo);
foreach (f in files) { ...
}
入れてみforeach(FileInfo f...
ましたが、別のエラーが発生します。
A local variable named 'f' cannot be declared in this scope because it would give a different meaning to 'f', which is already used in a 'parent or current' scope to denote something else
どうすれば修正できますか?