Go Back  Xtreme .NET Talk > .NET > Syntax Specific > Visual C# .NET > byref, out and things alike


Reply
 
Thread Tools Display Modes
  #1  
Old 03-20-2003, 03:05 AM
shouzama shouzama is offline
Freshman

Preferred language:
VB.NET
 
Join Date: Jan 2003
Location: Another World
Posts: 38
shouzama is on a distinguished road
Default byref, out and things alike

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

Code:
cDummy dummy_obj = new cDummy(dummyparams);
cDummy dymmy_copy = null;

In VB, an assignment like
Code:
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
Code:
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:
Code:
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?
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
ByRef Verses ByVal Mike Bailey General 6 02-23-2004 11:34 PM
byVal and byRef Phylum General 3 12-23-2003 02:13 AM
ByVal and ByRef rekam General 7 11-25-2003 06:33 AM
ByVal, ByRef ccc General 2 06-03-2003 10:34 AM

Advertisement:

Powered by liquidweb