Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/260.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C#分部类返回null_C#_Null_Infopath_Partial Classes - Fatal编程技术网

C#分部类返回null

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

我正在尝试创建、填充infopath模板并将其上载到sharepoint。我一直在遵循这些指示

下面是我所拥有的生成代码的示例

公共部分类myFields:

...
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";

常规信息
为空。您需要使用实例对其进行初始化。分部类与此问题无关。分部类是跨多个文件存在的单个类。就这样,谢谢。我刚把问题贴出来就意识到了这一点。它们是分部类,因为这是自动生成文件的方式。