473,466 Members | 1,439 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Beginners Question on 'return'

I just want to be sure about this. When I have code like this:

//data member
System.Drawing.Drawing2D.GraphicsPath graphicspath=new
System.Drawing.Drawing2D.GraphicsPath();

//method
public System.Drawing.Drawing2D.GraphicsPath GetGraphicsPath()
{
return graphicspath;
}

there is a reference, a pointer returned to 'graphicspath' and NOT a copy of
the object?
Sep 20 '06 #1
7 1143
Martijn Mulder wrote:
I just want to be sure about this. When I have code like this:

//data member
System.Drawing.Drawing2D.GraphicsPath graphicspath=new
System.Drawing.Drawing2D.GraphicsPath();

//method
public System.Drawing.Drawing2D.GraphicsPath GetGraphicsPath()
{
return graphicspath;
}

there is a reference, a pointer returned to 'graphicspath' and NOT a copy of
the object?
If GraphicsPath is a class, then the value returned is a reference.
If GraphicsPath is a struct, then the value returned is a shallow copy
of the data.

(I don't have the docs to hand to check which is the case, but it's
worth knowing the general principles.)

Jon

Sep 20 '06 #2
Hi, wot 's meaning of "shallow copy"?

"Jon Skeet [C# MVP]" <sk***@pobox.com>
??????:11*********************@i3g2000cwc.googlegr oups.com...
Martijn Mulder wrote:
>I just want to be sure about this. When I have code like this:

//data member
System.Drawing.Drawing2D.GraphicsPath graphicspath=new
System.Drawing.Drawing2D.GraphicsPath();

//method
public System.Drawing.Drawing2D.GraphicsPath GetGraphicsPath()
{
return graphicspath;
}

there is a reference, a pointer returned to 'graphicspath' and NOT a copy
of
the object?

If GraphicsPath is a class, then the value returned is a reference.
If GraphicsPath is a struct, then the value returned is a shallow copy
of the data.

(I don't have the docs to hand to check which is the case, but it's
worth knowing the general principles.)

Jon

Sep 20 '06 #3
"HuffmaN" <hu***********@gmail.comschrieb im Newsbeitrag
news:u1**************@TK2MSFTNGP02.phx.gbl...
Hi, wot 's meaning of "shallow copy"?
In this context it means:
A copy of the instance fields if the struct
fields of a valuetype are copied in the same way.
fields of a referencetype are set to the same instance.
>
"Jon Skeet [C# MVP]" <sk***@pobox.com>
??????:11*********************@i3g2000cwc.googlegr oups.com...
>Martijn Mulder wrote:
>>I just want to be sure about this. When I have code like this:

//data member
System.Drawing.Drawing2D.GraphicsPath graphicspath=new
System.Drawing.Drawing2D.GraphicsPath();

//method
public System.Drawing.Drawing2D.GraphicsPath GetGraphicsPath()
{
return graphicspath;
}

there is a reference, a pointer returned to 'graphicspath' and NOT a
copy of
the object?

If GraphicsPath is a class, then the value returned is a reference.
If GraphicsPath is a struct, then the value returned is a shallow copy
of the data.

(I don't have the docs to hand to check which is the case, but it's
worth knowing the general principles.)

Jon


Sep 20 '06 #4
HuffmaN wrote:
Hi, wot 's meaning of "shallow copy"?
Well, how did your Google search turn out? A Google search for:
"shallow copy" .NET
gives me lots of results which look promising.

It's always worth trying a simple search before asking a question.

Jon

Sep 20 '06 #5
Doesn't the method signature itself answer the question or indicate the
implied return type?

<%= Clinton Gallagher
NET csgallagher AT metromilwaukee.com
URL http://clintongallagher.metromilwaukee.com/
MAP 43°2'17"N 88°2'37"W : 43°2'17"N 88°2'37"W

"Jon Skeet [C# MVP]" <sk***@pobox.comwrote in message
news:11*********************@i3g2000cwc.googlegrou ps.com...
Martijn Mulder wrote:
>I just want to be sure about this. When I have code like this:

//data member
System.Drawing.Drawing2D.GraphicsPath graphicspath=new
System.Drawing.Drawing2D.GraphicsPath();

//method
public System.Drawing.Drawing2D.GraphicsPath GetGraphicsPath()
{
return graphicspath;
}

there is a reference, a pointer returned to 'graphicspath' and NOT a copy
of
the object?

If GraphicsPath is a class, then the value returned is a reference.
If GraphicsPath is a struct, then the value returned is a shallow copy
of the data.

(I don't have the docs to hand to check which is the case, but it's
worth knowing the general principles.)

Jon

Sep 20 '06 #6
clintonG <cs*********@REMOVETHISTEXTmetromilwaukee.comwrote :
Doesn't the method signature itself answer the question or indicate the
implied return type?
Well, it answers in terms of what the type is. It doesn't answer the
question as to how return values are handled, or fill in my ignorance
as to whether GraphicsPath is a struct or a class.

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet
If replying to the group, please do not mail me too
Sep 20 '06 #7
fill in my ignorance as to whether GraphicsPath is a struct or a class.
GraphicsPath is a class
Sep 20 '06 #8

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
by: Will | last post by:
Pardon two post in a row to the newsgroup but I want to try and expedite this, if you guys don't mind helping out... I running Windows XP Pro and wanted to download Python and any additional...
1
by: Doobai | last post by:
Hi, hope you can help, Just starting to learn about objects-relationals and I've come across what I hope is a little problem, when I try and make the method code, I get told the type already...
4
by: blah | last post by:
I m actually a Novice in Python as well as Linux, When i look up things on the internet about Linux Flavours, They are written so complex that it is difficult for me to understand, i am asking if...
4
by: Eggnog | last post by:
Hi, Is there a newsgroups for beginners questions? Cheers, Nawg
6
by: William Foster | last post by:
Does anyone know of a good online tutorial for C# focused on beginners. I have been to many great sites like csharpfriends, csharp-corner etc looking for good tutorials and have had no luck. Any...
4
by: aman firoz | last post by:
do you people got anything for c beginners..... help me out guys
0
by: Dual_b00t | last post by:
hi i created a site called PHP Together its for beginners also for gurus to help out the beginners if you are learning PHP and feel alone then drop by . ciao Mark
19
by: yltkhuu | last post by:
1. How does having a widely adopted C++ standard help game programmers? 2. What are the advantages ans disadvantages of employing the "using" directive? 3. Why might you define a new name for an...
6
by: Lars | last post by:
Hi all If this is the wrong list for beginners trouble I apologize. please refer to me the correct list in such case. I am trying to create a simple linked list but I keep getting segmentation...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.