Go Back   RunUO - Ultima Online Emulation > RunUO > New Join Forum

New Join Forum So your new to RunUO and looking to work with people that are new, this is the place.

Reply
 
Thread Tools Display Modes
Old 03-29-2004, 11:21 AM   #1 (permalink)
Forum Newbie
 
Join Date: Mar 2004
Posts: 97
Default Help with understanding References

I have been buring myself in books lately and am having trouble with the way this author is trying to explain the way References work within a script

For Example:

Code:
//build your PC
Computer desktop = new desktop();
desktop.brand = "Dell";
//it belongs to your company also
Computer yourCompaniesDesktop = desktop
//changing one changes the other
yourCompaniesDesktop.brand = "Gateway";
Console.WriteLine("your PC is a " + desktop.brand);
Now as the author says the output of this program would be "Gateway" and not "Dell". But im just not grasping the flow of this program at least in the way he is trying to explain it.

Could someone help to explain References to me?

Thanks in advance.
Muppet is offline   Reply With Quote
Old 03-30-2004, 03:28 PM   #2 (permalink)
Forum Expert
 
Join Date: Dec 2003
Age: 35
Posts: 462
Send a message via ICQ to dstarz20 Send a message via AIM to dstarz20
Default

It looks like since you PC is owned by the Company, that is the "Umbrella" your PC falls under. In other words, The Hirearchy is Your company than you so to speak. So, if you change something that is higher Hirearchy, it would affect anything under it or associated under it. Make since?
dstarz20 is offline   Reply With Quote
Old 03-30-2004, 03:42 PM   #3 (permalink)
I R TEH POSTING!!1!eleven
 
Join Date: Jan 2004
Posts: 1,617
Default

When a variable contains a value type, such as a string ("Blah") or int (42), it contains the actual sequence of bytes that make up that value (0x42 0x6c 0x61 0x68 0x00, and 0x2a 0x00 0x00 0x00 respectively), and copying the variable copies the contents byte-for-byte, creating a fresh copy of the value.

When a variable contains a reference type, it points to a sequence of bytes somewhere in memory. When the variable is copied, only the reference is copied, not the actual sequence of bytes. Both variables therefore contain a reference to the same sequence, and any change done via one variable is reflected in the other.
__________________
Get your C# documentation today!

Quote:
Originally Posted by Thorax
WOW! that is EXACTLY how i feel, to the T. There is nothing more powerfull than a well worded ass kicking.
badger badger badger badger badger badger badger badger badger badger badger badger...mushroom MUSHROOM
abralka@doramail.com
Ignacio Vazquez-Abrams is offline   Reply With Quote
Old 03-30-2004, 04:02 PM   #4 (permalink)
Forum Newbie
 
Join Date: Mar 2004
Posts: 97
Default

Much better understanding now thanks Ignacio.
Muppet is offline   Reply With Quote
Old 03-30-2004, 04:43 PM   #5 (permalink)
Forum Newbie
 
Join Date: Mar 2004
Posts: 97
Default

**Thinking out loud**

So what it seems like is that members of objects can be shared in thier references as long as the objects are in the same class.

So as long as i change the member "Brand" it will change the reference in both objects not just the member of the one object if they are of the same class.

hope you guys can follow that bable.

Is that right?
Muppet is offline   Reply With Quote
Old 03-30-2004, 05:05 PM   #6 (permalink)
 
Join Date: Feb 2004
Location: Canada eh
Posts: 413
Default

Perhaps if you take a peek at this guys site you might be able to follow it through a bit better.

http://www.jaggersoft.com/csharp_course/index.html

I found his diagrams showing the data and pointers as they're implemented between the stack and the heap to greatly clarify things for myself.
---------------------------------------------------------
awdball (old school c coder learning and luvin c#)
__________________
awdball
awdball is offline   Reply With Quote
Old 03-30-2004, 05:54 PM   #7 (permalink)
I R TEH POSTING!!1!eleven
 
Join Date: Jan 2004
Posts: 1,617
Default

Quote:
Originally Posted by Muppet
**Thinking out loud**

So what it seems like is that members of objects can be shared in thier references as long as the objects are in the same class.

So as long as i change the member "Brand" it will change the reference in both objects not just the member of the one object if they are of the same class.

hope you guys can follow that bable.

Is that right?
No. There is only one object, with two references to it.
__________________
Get your C# documentation today!

Quote:
Originally Posted by Thorax
WOW! that is EXACTLY how i feel, to the T. There is nothing more powerfull than a well worded ass kicking.
badger badger badger badger badger badger badger badger badger badger badger badger...mushroom MUSHROOM
abralka@doramail.com
Ignacio Vazquez-Abrams is offline   Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
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
Trackbacks are Off
Pingbacks are Off
Refbacks are Off



Powered by vBulletin® Version 3.7.0
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.2.0 RC5