C#分部类返回null
我正在尝试创建、填充infopath模板并将其上载到sharepoint。我一直在遵循这些指示 下面是我所拥有的生成代码的示例 公共部分类myFields:C#分部类返回null,c#,null,infopath,partial-classes,C#,Null,Infopath,Partial Classes,我正在尝试创建、填充infopath模板并将其上载到sharepoint。我一直在遵循这些指示 下面是我所拥有的生成代码的示例 公共部分类myFields: ... public partial class myFields { private General_Information general_InformationField; ... public General_Information General_Information { get
...
public partial class myFields
{
private General_Information general_InformationField;
...
public General_Information General_Information
{
get
{
return this.general_InformationField;
}
set
{
this.general_InformationField = value;
}
}
...
}
...
公共部分类通用信息
public partial class General_Information
{
private string wellField;
...
public string Well
{
get
{
return this.wellField;
}
set
{
this.wellField = value;
}
}
...
这些说明填充以下数据:
myFields fields = new myFields();
fields.Name = "Joe";
fields.Surname = "Blogs";
当我试图在网站上效仿这个例子时:
myFields fields = new myFields();
fields.General_Information.Well = "name";
我收到一个错误,说myFields.General\u Information.*get**返回空值。
正确的方法是什么?
fields.General\u Information.Well=“name”代码>应该在下面。您忘记实例化General\u Information
类型,因此它是空的。此外,不确定将它们作为部分类需要什么。实际上不应该
fields.General_Information gi = new General_Information();
gi.Well = "name";
常规信息
为空。您需要使用实例对其进行初始化。分部类与此问题无关。分部类是跨多个文件存在的单个类。就这样,谢谢。我刚把问题贴出来就意识到了这一点。它们是分部类,因为这是自动生成文件的方式。