我使用的API提供了此代码。
public partial class getMerchant : object, System.ComponentModel.INotifyPropertyChanged
{
private int[] iMerchantIdField;
/// <remarks/>
[System.Xml.Serialization.XmlElementAttribute("iMerchantId", Form = System.Xml.Schema.XmlSchemaForm.Unqualified, Order = 0)]
public int[] iMerchantId
{
get
{
return this.iMerchantIdField;
}
set
{
this.iMerchantIdField = value;
this.RaisePropertyChanged("iMerchantId");
}
}
}
现在我正在尝试创建此类的对象并运行它:
private void btnShowResult_Click(object sender, EventArgs e)
{
Awin.ApiPortTypeClient client = new Awin.ApiPortTypeClient();
UserAuthentication userAuthentication = new UserAuthentication();
userAuthentication.sApiKey = "111";
getMerchant merchant = new getMerchant();
merchant.iMerchantId[0] = 2518;
merchant.iMerchantId[1] = 3030;
var response = client.getMerchant(userAuthentication, merchant);
lblResult.Text = response[0].sName.ToString();
}
但是每当我尝试运行它时,当编译器命中行merchant时,它会给出nullreferenceexception.iMerchantId [0] = 2518; 到目前为止我所理解的是,这个iMerchantId []还没有被宣布。但问题是我无法找到答案如何申报。
我很感谢能得到的任何帮助。