Click here to Skip to main content
15,881,812 members
Home / Discussions / C#
   

C#

 
AnswerRe: C# Newbie Please Help! Pin
pbraun18-Apr-07 14:44
pbraun18-Apr-07 14:44 
GeneralRe: C# Newbie Please Help! Pin
ashley4838518-Apr-07 14:51
ashley4838518-Apr-07 14:51 
GeneralRe: C# Newbie Please Help! Pin
pbraun18-Apr-07 15:02
pbraun18-Apr-07 15:02 
GeneralRe: C# Newbie Please Help! Pin
ashley4838518-Apr-07 15:09
ashley4838518-Apr-07 15:09 
GeneralRe: C# Newbie Please Help! Pin
pbraun18-Apr-07 15:24
pbraun18-Apr-07 15:24 
Questionpassing "this" by reference Pin
cbin18-Apr-07 14:25
cbin18-Apr-07 14:25 
AnswerRe: passing "this" by reference Pin
Luc Pattyn18-Apr-07 14:48
sitebuilderLuc Pattyn18-Apr-07 14:48 
AnswerRe: passing "this" by reference Pin
Tim Paaschen18-Apr-07 19:43
Tim Paaschen18-Apr-07 19:43 
Hi,

as Luc already suggested, you can just drop the 'ref' from your method's parameter and everything should work. I will just add some explanation why you must not pass 'this' as a ref parameter.

If you have a value object (a struct) and you pass it by value (no 'ref' parameter) to the method, the method gets its own copy and the original will not be affected by any changes made in the method. If the value object is passed by reference, all changes do affect the original.
If you have a reference object (a class) and you pass it by value, the reference itself is copied. Thus you have two references to the same object. If the method changes the referenced object, the changes will affect the original. However, if the method changes the reference itself (e.g. set it to 'null'), this will not affect the original reference. If you pass the reference object as a reference parameter, you are able not only to manipulate the referenced object but also the reference itself. Sometimes this is the desired behaviour, but you definitely don't want enable any method to set your 'this' reference to 'null'. Therefore 'this' is read-only and must not be passed by reference.

Hope this helps.


Regards,
Tim

QuestionReading data from one application to another Pin
yirmyah18-Apr-07 12:45
yirmyah18-Apr-07 12:45 
AnswerRe: Reading data from one application to another Pin
Christian Graus18-Apr-07 14:45
protectorChristian Graus18-Apr-07 14:45 
GeneralRe: Reading data from one application to another Pin
yirmyah18-Apr-07 15:19
yirmyah18-Apr-07 15:19 
GeneralRe: Reading data from one application to another Pin
Dave Kreskowiak18-Apr-07 15:31
mveDave Kreskowiak18-Apr-07 15:31 
QuestionUsing Databound ComboBox Pin
polishprogrammer18-Apr-07 12:03
polishprogrammer18-Apr-07 12:03 
QuestionRichTextBox Pin
Saikek18-Apr-07 11:29
Saikek18-Apr-07 11:29 
AnswerRe: RichTextBox Pin
Judah Gabriel Himango18-Apr-07 15:56
sponsorJudah Gabriel Himango18-Apr-07 15:56 
QuestionC# and C++ Pin
netJP12L18-Apr-07 10:31
netJP12L18-Apr-07 10:31 
AnswerRe: C# and C++ Pin
Christian Graus18-Apr-07 10:45
protectorChristian Graus18-Apr-07 10:45 
AnswerRe: C# and C++ Pin
pbraun18-Apr-07 14:58
pbraun18-Apr-07 14:58 
GeneralRe: C# and C++ Pin
Christian Graus18-Apr-07 16:06
protectorChristian Graus18-Apr-07 16:06 
GeneralRe: C# and C++ Pin
netJP12L18-Apr-07 16:19
netJP12L18-Apr-07 16:19 
GeneralRe: C# and C++ Pin
pbraun18-Apr-07 18:07
pbraun18-Apr-07 18:07 
QuestionC# Web Service not running Pin
dancelicious18-Apr-07 9:02
dancelicious18-Apr-07 9:02 
AnswerRe: C# Web Service not running Pin
_mubashir18-Apr-07 9:34
_mubashir18-Apr-07 9:34 
GeneralRe: C# Web Service not running Pin
dancelicious18-Apr-07 9:42
dancelicious18-Apr-07 9:42 
GeneralRe: C# Web Service not running Pin
dancelicious18-Apr-07 9:49
dancelicious18-Apr-07 9:49 

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.