Click here to Skip to main content
15,898,744 members
Home / Discussions / C#
   

C#

 
AnswerRe: windows forms application using workflow c# Pin
Kevin McFarlane17-Jun-08 21:59
Kevin McFarlane17-Jun-08 21:59 
QuestionReportViewer: How to get current subreport title in parent report header Pin
OregonGhost17-Jun-08 0:45
OregonGhost17-Jun-08 0:45 
QuestionBusiness classes in windows application and webservice implement same interface Pin
N a v a n e e t h17-Jun-08 0:32
N a v a n e e t h17-Jun-08 0:32 
QuestionHow can I detect the decimal separator of the current host? Pin
bouli17-Jun-08 0:31
bouli17-Jun-08 0:31 
AnswerRe: How can I detect the decimal separator of the current host? Pin
DaveyM6917-Jun-08 0:40
professionalDaveyM6917-Jun-08 0:40 
AnswerRe: How can I detect the decimal separator of the current host? Pin
DaveyM6917-Jun-08 0:44
professionalDaveyM6917-Jun-08 0:44 
Questionpass by value Pin
DaveyM6917-Jun-08 0:16
professionalDaveyM6917-Jun-08 0:16 
AnswerRe: pass by value Pin
Simon P Stevens17-Jun-08 0:40
Simon P Stevens17-Jun-08 0:40 
It's easy to get confused by this.

If you try to forcable pass a value type by reference, what is happening behind the scences is the value type is being stuck in a reference type box (refereed to as being 'boxed') and it is a reference to this box that is passed.

With a reference type what you have is actually a pointer (or reference) to the object that is stored in the heap. By default you pass that pointer _by value_. You are already passing a pointer to a reference type by value.

(If you add the ref keyword, you will be then passing a pointer to a reference type by reference. Therefore you end up passing a reference to a reference.)

It isn't possible to pass a reference type by value because the object only exists on the heap. If you create a struct the struct will only contain a pointer to the reference type on the heap, so passing the struct by value will still provide the same pointer to the same object on the heap.

The only way to really achive this effect is to do some form of deep copy the object and pass that instead.

Why do you want to pass a reference type by value?

Simon

GeneralRe: pass by value Pin
Guffa17-Jun-08 0:50
Guffa17-Jun-08 0:50 
GeneralRe: pass by value Pin
Simon P Stevens17-Jun-08 1:07
Simon P Stevens17-Jun-08 1:07 
GeneralRe: pass by value Pin
Guffa17-Jun-08 3:21
Guffa17-Jun-08 3:21 
GeneralRe: pass by value Pin
DaveyM6917-Jun-08 0:55
professionalDaveyM6917-Jun-08 0:55 
GeneralRe: pass by value Pin
Simon P Stevens17-Jun-08 1:19
Simon P Stevens17-Jun-08 1:19 
AnswerRe: pass by value Pin
RugbyLeague17-Jun-08 0:48
RugbyLeague17-Jun-08 0:48 
GeneralRe: pass by value Pin
DaveyM6917-Jun-08 0:58
professionalDaveyM6917-Jun-08 0:58 
GeneralRe: pass by value Pin
RugbyLeague17-Jun-08 1:00
RugbyLeague17-Jun-08 1:00 
AnswerRe: pass by value Pin
N a v a n e e t h17-Jun-08 0:49
N a v a n e e t h17-Jun-08 0:49 
GeneralRe: pass by value Pin
DaveyM6917-Jun-08 0:59
professionalDaveyM6917-Jun-08 0:59 
AnswerRe: pass by value Pin
CPallini17-Jun-08 0:50
mveCPallini17-Jun-08 0:50 
GeneralRe: pass by value Pin
DaveyM6917-Jun-08 1:00
professionalDaveyM6917-Jun-08 1:00 
GeneralRe: pass by value Pin
Guffa17-Jun-08 1:08
Guffa17-Jun-08 1:08 
GeneralRe: pass by value Pin
Christian Flutcher17-Jun-08 1:31
Christian Flutcher17-Jun-08 1:31 
GeneralRe: pass by value Pin
Simon P Stevens17-Jun-08 1:37
Simon P Stevens17-Jun-08 1:37 
AnswerRe: pass by value Pin
V.17-Jun-08 2:50
professionalV.17-Jun-08 2:50 
GeneralRe: pass by value Pin
Simon P Stevens17-Jun-08 3:06
Simon P Stevens17-Jun-08 3:06 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.