本文介绍了可能的编译器错误(C#3.0)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 29岁程序员,3月因学历无情被辞! 附加程序无法编译。错误消息说: "名为''i'的局部变量不能在此范围内声明,因为它会给'i'赋予不同的含义',已经在''孩子'中使用了' 范围来表示别的东西 - 这没有多大意义。这是一个编译错误吗? TJ class program { static void Main( string [] args) { switch(0){ case 0: for(int i = 0 ;;){ } 案例1: //错误CS0136:名为我的局部变量不能是在这个范围内声明了 ,因为它会给''i'赋予不同的含义,这已经在''子'范围内使用了来表示别的东西 int i = 0; } } } 解决方案 Console.Writeline(i.ToString( )); //如果以上编译,则显示i值,那就是 IN_SCOPE并已经宣布。 The attached program does not compile. The error message says:"A local variable named ''i'' cannot be declared in this scope because itwould give a different meaning to ''i'', which is already used in a ''child''scope to denote something else"- which does not make much sense. Is it a compiles bug?TJclass Program{static void Main(string[] args){switch (0) {case 0:for (int i = 0; ; ) {}case 1:// error CS0136: A local variable named ''i'' cannot be declaredin this scope because it would give a different meaning to ''i'', which isalready used in a ''child'' scope to denote something elseint i = 0;}}} 解决方案Console.Writeline( i.ToString());//if the above compiles, and it shows the "i" value, then it isIN_SCOPE and already declared. 这篇关于可能的编译器错误(C#3.0)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 上岸,阿里云!
08-01 12:21