This is not a problem. Even objects passed byval are updatable (you just
allows to update or not *this* pointer).
Patrice
--
"Mike Guerrieri" <MikeGuerrieri@discussions.microsoft.com> a écrit dans le
message de news:D0F5FA17-242F-4AA5-8B65-B2E65A0224ED@microsoft.com...[color=blue]
> Thank you Jon, I didn't realize that the variable used in a foreach is[/color]
always[color=blue]
> implicitly readonly.
>
> I don't believe that I'm confused by reference and value types. For each
> Address object in my collection, when the data from an Address object is
> inserted into the database an AddressID will be returned in an output
> parameter. I want to populate the AddressID property of the Address object
> with that ID.
>
> Thank you very much for your help.
>
> ~ Mike G.
>
>
> "Jon Skeet [C# MVP]" wrote:
>[color=green]
> > Mike Guerrieri <MikeGuerrieri@discussions.microsoft.com> wrote:[color=darkred]
> > > Thanks for the fast reply Scott. The contactAddress is not marked[/color][/color][/color]
ReadOnly,[color=blue][color=green][color=darkred]
> > > here is the section where it is created...
> > >
> > > dtaContactAddress contactAddressData = new dtaContactAddress();
> > > foreach (ContactAddress contactAddress in contact.AddressCollection)
> > > {
> > > contactAddress.ContactId = contactID;
> > > contactAddressData.Insert(ref contactAddress);
> > > }
> > >
> > > Could it be that objects in a collection are implicitly ReadOnly?[/color]
> >
> > Objects themselves aren't readonly. However, the *variable*
> > contactAddress is readonly - the variable used in a foreach is always
> > implicitly readonly.
> >
> > It doesn't look to me like you need to pass contactAddress by reference
> > though - that would just allow Insert to change the value of
> > contactAddress, which itself is a reference.
> >
> > I *suspect* you're a bit confused about reference types vs value types
> > and parameter passing.
> > See
http://www.pobox.com/~skeet/csharp/parameters.html
> >
> > --
> > Jon Skeet - <skeet@pobox.com>
> >
http://www.pobox.com/~skeet
> > If replying to the group, please do not mail me too
> >[/color][/color]