我查看了 google 和其他 stackoverflowUse of unassigned local variable
错误,但仍然找不到答案。我认为也许我的错误是因为滥用了 ExtractionCtrl 的范围。我尝试了这段代码来测试范围并且它有效。所以我现在不知道我的错误在哪里。
测试范围
namespace RandomTesting
{
internal class Program
{
private static void Main(string[] args)
{
int x = 5;
switch (x)
{
case 2:
System.Console.WriteLine("Your # is 2");
break;
case 5:
System.Console.WriteLine("Your # is :{0}", x);
x = x + 2;
System.Console.WriteLine("Your # is :{0}", x);
break;
}
System.Console.WriteLine("Your # is :{0}", x);
Console.ReadLine();
}
}
}
主要代码的一部分
switch (arg)
{
case "AR":
ExtractionCtrl = new ARExtractionController();
// add new mapping here
break;
case "ICN":
ExtractionCtrl = new IcnExtractionController();
// add new mapping here
break;
}
int ticketID;
if (int.TryParse(arg, out ticketID))
{
string returnedFilePath = ExtractionController.GetStartupPath();
ExtractionCtrl.Extract(ticketID, returnedFilePath, AR_TEMPLATE_PATH, MAPPING_PATH);
}