Re: Object Parameters, they are passed as pointers, yes?
From: Stoitcho Goutsev \(100\) [C# MVP] (100_at_100.com)
Date: 02/05/04
- Next message: discussion_at_discussion.microsoft.com: "Firewire cameras"
- Previous message: Antenna: "Re: Object Parameters, they are passed as pointers, yes?"
- In reply to: Derrick: "Object Parameters, they are passed as pointers, yes?"
- Next in thread: Jon Skeet [C# MVP]: "Re: Object Parameters, they are passed as pointers, yes?"
- Messages sorted by: [ date ] [ thread ]
Date: Thu, 5 Feb 2004 09:40:54 -0500
Hi Derrick,
> I saw the ref param keyword relating to base types. Just checking, if I
> pass an object around to other class constructors, there will only be one
> instance of the object, correct?
Yes, if the object is an instance of reference type (class). If the
paramter is of valuetype (struct, enum) you will have a copy of that object
for each of the classes.
But if you have parameter of type *object*
void Foo(object param)
{
}
That param might be reference to an instance of a class or boxed valuetype.
Eventhough you might share the reference to a boxed value type in the
managed heap you cannot use it for sharing data because to use the type
(read/write its properties and fields call some of its methods) you have to
unbox that valuetype and then you will have a private copy. Thus, the
changes won't go in the original.
B\rgds
100
- Next message: discussion_at_discussion.microsoft.com: "Firewire cameras"
- Previous message: Antenna: "Re: Object Parameters, they are passed as pointers, yes?"
- In reply to: Derrick: "Object Parameters, they are passed as pointers, yes?"
- Next in thread: Jon Skeet [C# MVP]: "Re: Object Parameters, they are passed as pointers, yes?"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|