を初期化:私は、実行時にクラスの複数のインスタンスを作成しても、初期化したいために、次のコードを試みていますが、それはエラーを与えている、実行時にクラスのインスタンスを作成し、同時に
A local variable named 'inum' cannot be declared in this scope because it would give a different meaning to 'inum', which is already used in a 'parent or current' scope to denote something else.
public class MyClass
{
static int i=0;
class A
{
public A()
{
}
}
public static void Run()
{
string inum = "i";
for (int j=1;j<=5;j++)
{
inum = inum + j.ToString();
//Initialize Instance
A inum = new A();
}
}
}
この例ではなく実際に何をしようとしているのかをもっと詳しく説明してください。 – Henrik
エラーメッセージは何が間違っているかを正確に伝えています:あなたは 'inum'という名前の文字列と第2の変数' A inum'を持つ内部ループを持っています。 2番目の名前を変更して、外側と競合しないようにします。 – asawyer
2番目の変数名が変更されています。連結を見ることができます。 – RKh