【发布时间】:2014-01-24 16:29:18
【问题描述】:
我有一个部分类的两个部分:
public partial class Class1 : AnotherClass
{
int id;
}
public partial class Class1
{
public void func()
{
//here i need to access the id variable defined in the other part
id = 1; //this instruction raise an error "The name 'id' does not exists in the current context"
}
}
如何访问该变量?
【问题讨论】:
-
我编辑了标题,希望能更好地传达真正的问题。
-
您的实际问题是,为什么需要在另一个部分声明未初始化的变量(即现在它不再是部分了)。
-
@Steve 对不起,我忘记了函数!
-
@MauriceStam 我已经简化了我的真实情况
-
命名空间一样吗?
标签: c# partial-classes