I've consumed a web service with two classes "address" and "request." One of the properties of the request object is an array of address objects:
request _req = new request();
_req.addresses = // expecting address[]
I know I'm doing this wrong (as I keep getting exception errors) so I'm hoping someone can help me out. How do I create an array of address objects and set the "_req.addresses" value equal to that object (address[])? I get an "object reference not set to an instance..." error on the second line, when trying to set the city value equal to the string _q.LocationA.City... so these aren't working:
address[] _address = new address[1];
_address[0].city = _q.LocationA.City;
_address[0].state = _q.LocationA.State;
_address[0].street = _q.LocationA.Address;
_address[0].zipCode = _q.LocationA.Zip;
request _req = new request();
_req.addresses = _address;
And I've tried this:
address _address = new address();
_address.city = _q.LocationA.City;
_address.state = _q.LocationA.State;
_address.street = _q.LocationA.Address;
_address.zipCode = _q.LocationA.Zip;
request _req = new request();
_req.addresses[0] = _address;
new request(), is adresses == null ?