byref, out and things alike

shouzama

Freshman
Joined
Jan 20, 2003
Messages
38
Location
Another World
Coming straight from VB6 (and .NET) to C#, I encountered some "logistic" problems in the way the new MS language handles objects and structs.

Let's suppose we have

C#:
cDummy dummy_obj = new cDummy(dummyparams);
cDummy dymmy_copy = null;

In VB, an assignment like
Visual Basic:
dummy_copy = dummy_obj
simply makes dummy_copy reference the same object referenced by dummy_obj.

So, my first question is:
- In c#, does the same thing happen?

Let's go a little further.
Suppose we have a class with a private object of class cDummy, and a property that returns this object
C#:
private cDummy dummy_obj;

public property GetObject
{
    get
    {
        return dummy_obj;
    }
}

- Does the property returns a COPY of the object or a REFERENCE to the object?
If I do:
C#:
cDummy dummy_copy;
dummy_copy = dummyclass.GetObject;
does dummy_copy hold a copy of the object in dummyclass OR a reference to the same object?

And WHY I can't pass "byref dummyclass.GetObject" to functions?
 
Back
Top