不正确的“未使用参考用途”在switch语句中 [英] Incorrect "reference use unreached" in switch statement

查看:65
本文介绍了不正确的“未使用参考用途”在switch语句中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

以下switch语句产生"reference use unreached"警告7次与"开关"一致关键词。 7 - 是案例分支的数量。

The following switch statement produces "reference use unreached" warnings 7 times in line with "switch" keyword. 7 - is the number of case branches.


namespace TestApp
{
  class Program
  {
    static void Main(string[] args)
    {
      if (args.Length > 0)
      {
        switch (args[0])
        {
          case "String 1": break;
          case "String 2": break;
          case "String 3": break;
          case "String 4": break;
          case "String 5": break;
          case "String 6": break;
          case "String 7": break;
        }
      }
    }
  }
}

推荐答案

是的,它与C#编译器生成代码的方式有关。在这种情况下(> =  7),它会生成字典和切换指令。

Yes, it has to do with the way the C# compilers generate the code. In this case (>=  7)it generates a dictionary and the switch instruction.

"参考用途" "编程"是指由编译器创建的这个临时字典,"正常"字符不能达到该字典。该计划的流程。

The "reference use" refers to this temp dictionary created by the compiler, which is not reached by the "normal" flow of the program.

 

谢谢,

f

 


这篇关于不正确的“未使用参考用途”在switch语句中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆