简体   繁体   English

在Web服务的数组中传递值

[英]Passing value in an array in webservice

This is my code in the webservice 这是我在网络服务中的代码

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

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

and when I pass a value to it using 当我使用传递一个值

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

I receive an error 我收到一个错误

Object reference not set to an instance of an object. 你调用的对象是空的。

I really do not know whats happening 我真的不知道发生了什么

Any ideas? 有任何想法吗?

you need to initialize the list in client side 您需要在客户端初始化列表

AuditTrail auditclass = new AuditTrail(); 

auditclass.MyObjectVariableList = new object[7];

or in service class constructor initialize the property value 或在服务类构造函数中初始化属性值

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