G
Guest
I have a few objects that I've created, Contact, Address, AddressCollection
(inherits from CollectionBase), dtaContact, and dtaAddress. One of the
properties of the Contact object (Contact.Addresses) is a Type of
AddressCollection. When I want to add a new contact to my database I create a
new Address object for each address and a new AddressCollection object. I
then populate the Address objects and add them to the AddressCollection
(InnerList.Add(address)). Next I populate the Contact object properties
including the AddressCollection. Now I want to pass the Contact object by Ref
to the dtaContact.Insert() method so that I can use the output parameter of
my SP to populate the ContactID property and have that value reflected in my
contact object. This functionality works just fine. However within my
dtaContact.Insert() method I want to loop through the AddressCollection and
pass each Address object by Ref to the dtaAddress.Insert method. When I do
this I get the following error when I try to Rebuild...
error CS1605: Cannot pass 'contactAddress' as a ref or out argument because
it is read-only
Can anyone provide some insight as to why this may be happening?
Thanks,
Mike G.
(inherits from CollectionBase), dtaContact, and dtaAddress. One of the
properties of the Contact object (Contact.Addresses) is a Type of
AddressCollection. When I want to add a new contact to my database I create a
new Address object for each address and a new AddressCollection object. I
then populate the Address objects and add them to the AddressCollection
(InnerList.Add(address)). Next I populate the Contact object properties
including the AddressCollection. Now I want to pass the Contact object by Ref
to the dtaContact.Insert() method so that I can use the output parameter of
my SP to populate the ContactID property and have that value reflected in my
contact object. This functionality works just fine. However within my
dtaContact.Insert() method I want to loop through the AddressCollection and
pass each Address object by Ref to the dtaAddress.Insert method. When I do
this I get the following error when I try to Rebuild...
error CS1605: Cannot pass 'contactAddress' as a ref or out argument because
it is read-only
Can anyone provide some insight as to why this may be happening?
Thanks,
Mike G.