因此,我正在尝试为我的整个程序创建一个可公开访问的字典,我在我的表单下创建了这样的字典:
public static Dictionary<string, int> categories = new Dictionary<string, int>
{
{"services", 0},
{"files", 0},
{"shortcuts", 0},
{"registry", 0},
{"browsers", 0}
};
Run Code Online (Sandbox Code Playgroud)
现在,在私有方法内部,我有这样的代码:
foreach (KeyValuePair<string, int> reference in categories)
{
for (int i = 0; i < scanLines.Count; i++)
{
if (scanLines[i].Contains(reference.Key))
{
start = i + 1;
break;
}
}
for (int i = start; i < scanLines.Count; i++)
{
if (scanLines[i].Contains("*"))
{
stop = i - 1;
break;
}
}
// Write the result for the category by …Run Code Online (Sandbox Code Playgroud)