Re: DataRow confusion!!!
- From: "Dave" <NOSPAM-dave@xxxxxxxxxxxxxxxxxxxxxxx>
- Date: Thu, 21 Apr 2005 22:44:33 -0400
No, the pointer to the object on the heap is copied. The data is unchanged.
Instead, use DataRow.ItemArray or DataTable.Clone to pass in a copy of the data.
--
Dave Sexton
dave@xxxxxxxxxxxxxxxxxxx
-----------------------------------------------------------------------
"Job Lot" <JobLot@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message news:36971BF9-087C-4D2E-A453-A88B8A6BB4B9@xxxxxxxxxxxxxxxx
> But isn't it true that when a variable is passed ByRef then a pointer to
> memory address is passed and when passed ByVal a copy of variable is passed.
> So, when we pass variable of type DataRow as ByVal shouldn't a copy of
> variable is passed rather than a pointer to memory address
>
> "Joshua Flanagan" wrote:
>
>> > When I edited value in the textbox, the changes where written back to the
>> > DataGrid. How it could happen, even though I passed row ByVal and not by
>> > ByRef?
>>
>> Passing objects ByVal means that the value of the variable (which
>> contains a memory address) is copied to the new function. This does not
>> mean the object data itself is copied to the new function. Simply the
>> memory address, which references the object. If you change the object
>> that your "row" variable points to within the form - for example, row =
>> new DataRow() - the external source will not be affected. However, if
>> you change the data stored within the DataRow object, both references
>> (the one within the form, and the one outside of the form) will see the
>> changes, since they point to the same object.
>>
>> Passing an object ByRef is only used if you want to change which object
>> a variable references.
>>
>>
>> Joshua Flanagan
>> http://flimflan.com/blog
>>
.
- References:
- DataRow confusion!!!
- From: Job Lot
- Re: DataRow confusion!!!
- From: Joshua Flanagan
- Re: DataRow confusion!!!
- From: Job Lot
- DataRow confusion!!!
- Prev by Date: Re: Deleting rows in Access database table
- Next by Date: Re: using datagrid field values in multiple forms
- Previous by thread: Re: DataRow confusion!!!
- Next by thread: Re: DataRow confusion!!!
- Index(es):
Relevant Pages
|