无法纠正错误 [英] Unable to rectify errors
本文介绍了无法纠正错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我在我的代码的一部分下面给出了。在调试时我得到两个错误:
1.在这个范围内不能声明一个名为'c1'的局部变量,因为它会给'ç1'带来不同的含义已经在父级或当前范围内用于表示其他内容。
2.无法隐式转换类型'int'到'int [] []'。
我的代码在这里:
I am giving underneath a part of my code. While debugging I get two errors:
1. A local variable named 'c1' cannot be declared in this scope because it would give a different meaning to 'ç1'which is already used in a 'parent or current' scope to denote something else.
2. Cannot implicitly convert type 'int'to 'int[][]'.
My code is here:
for (i = 1; i <= m; i++)
{
for (j = 1; j <= n; j++)
{
Console.WriteLine("Enter the values for c1[i][j]");
int[][] c1 = Convert.ToInt32(Console.ReadLine()); //****error in this line
}
}
我该如何纠正这个错误?
How should I rectify this error?
推荐答案
这里有什么不清楚的错误信息?只需重命名此c1
。你在其他地方有另一个带有这个名字的变量。
你自己一个大忙,不要使用这些名字,总是使用语义上合理的东西。请参阅(好的)Microsoft命名约定。
-SA
What is unclear in this error message? Just rename thisc1
. You have another variable with this name elsewhere.
And do yourself a big favor, don't use such names, always uses something semantically sensible. Refer to (good) Microsoft naming conventions.
—SA
您可以编写代码像这样
You can write your code like this
for (int i = 1; i <= m; i++)
{
for (int j = 1; j <= n; j++)
{
Console.WriteLine("Enter the values for c1[i][j]");
c1[i][j] = Convert.ToInt32(Console.ReadLine()); //**** this will not show any error
}
}
希望它能起作用
hope it will work
这篇关于无法纠正错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文