簡體   English   中英

在Web服務的數組中傳遞值

[英]Passing value in an array in webservice

這是我在網絡服務中的代碼

private object[] _myObjectVariableList = new object[7];

public object[] MyObjectVariableList
{
    get { return _myObjectVariableList; }
    set { _myObjectVariableList = value; }
}

當我使用傳遞一個值

 AuditTrail auditclass = new AuditTrail();
 auditclass.MyObjectVariableList[indexCounter] = myTextBox.Text;

我收到一個錯誤

你調用的對象是空的。

我真的不知道發生了什么

有任何想法嗎?

您需要在客戶端初始化列表

AuditTrail auditclass = new AuditTrail(); 

auditclass.MyObjectVariableList = new object[7];

或在服務類構造函數中初始化屬性值

public class AuditTrail 
{
    private object[] _myObjectVariableList;

    public object[] MyObjectVariableList
    {
        get { return _myObjectVariableList; }
        set { _myObjectVariableList = value; }
    }
    public AuditTrail()
    {
        MyObjectVariableList= new object[7];
    }
}

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM