是否可以像这样将普通类与部分类结合起来:
public class ClassA
{
public string PropertyA {get; set;}
}
public partial class ClassA
{
public string PropertyB {get; set;}
}
代码的结果应该是:
var instance = new ClassA();
instance.PropertyA = "Something";
instance.PropertyB = "Something else";
C# 支持这种模式吗?
提前谢谢大家!
最佳答案
简短回答:否 MSDN 声明here :
All the parts must use the partial keyword. All of the parts must be available at compile time to form the final type. All the parts must have the same accessibility, such as public, private, and so on.
关于c# - 将部分类与普通类相结合,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10991214/