Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/335.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# 设置类属性的问题_C#_Properties - Fatal编程技术网

C# 设置类属性的问题

C# 设置类属性的问题,c#,properties,C#,Properties,我一直在得到一个空的异常;在下面ApiUsername和ApiPassword都有值,所以我不会怀疑我是否设置了错误的密码。凭据属性是需要设置用户名和密码属性的特定类型 所以我定义了自动属性: public CustomSecurityHeaderType SoapCallCredentials{get;private set;} 然后,无论何时命中,我都会得到一个空异常,并且不知道为什么 private void SetApiCredentials() { SoapCallCreden

我一直在得到一个空的异常;在下面ApiUsername和ApiPassword都有值,所以我不会怀疑我是否设置了错误的密码。凭据属性是需要设置用户名和密码属性的特定类型

所以我定义了自动属性: public CustomSecurityHeaderType SoapCallCredentials{get;private set;}

然后,无论何时命中,我都会得到一个空异常,并且不知道为什么

private void SetApiCredentials()
{
    SoapCallCredentials = new CustomSecurityHeaderType
    {
        Credentials = 
        {
            Username = PayPalConfig.CurrentConfiguration.ApiUserName,
            Password = PayPalConfig.CurrentConfiguration.ApiPassword
        }
    };

    UrlEndPoint = PayPalConfig.CurrentConfiguration.ExpressCheckoutSoapApiEndPoint;
}

我想你需要一个新的

Credentials = new WhatEverThisTypeIs()
{
    Username = PayPalConfig.CurrentConfiguration.ApiUserName,
    Password = PayPalConfig.CurrentConfiguration.ApiPassword
}

我想你需要一个新的

Credentials = new WhatEverThisTypeIs()
{
    Username = PayPalConfig.CurrentConfiguration.ApiUserName,
    Password = PayPalConfig.CurrentConfiguration.ApiPassword
}

首先需要实例化凭据,如:

Credentials = new UserIdPasswordType()

首先需要实例化凭据,如:

Credentials = new UserIdPasswordType()

您的凭据声明中是否缺少
new
?我想是的,但让我再试一次。您的凭据声明中是否缺少
new
?我想是的,但让我再试一次。