Click here to Skip to main content
15,892,161 members
Home / Discussions / C#
   

C#

 
QuestionTab Order Pin
Saiyed Alam30-Jul-07 8:08
Saiyed Alam30-Jul-07 8:08 
AnswerRe: Tab Order Pin
Martin#30-Jul-07 8:09
Martin#30-Jul-07 8:09 
GeneralRe: Tab Order Pin
Saiyed Alam30-Jul-07 8:15
Saiyed Alam30-Jul-07 8:15 
AnswerRe: Tab Order Pin
Luis Alonso Ramos30-Jul-07 8:44
Luis Alonso Ramos30-Jul-07 8:44 
AnswerRe: Tab Order Pin
Paul Conrad30-Jul-07 10:44
professionalPaul Conrad30-Jul-07 10:44 
QuestionReference as a 'pointer' to a value type Pin
kildareflare30-Jul-07 7:37
kildareflare30-Jul-07 7:37 
AnswerRe: Reference as a 'pointer' to a value type Pin
Bert delaVega30-Jul-07 8:02
Bert delaVega30-Jul-07 8:02 
AnswerRe: Reference as a 'pointer' to a value type Pin
Luc Pattyn30-Jul-07 8:15
sitebuilderLuc Pattyn30-Jul-07 8:15 
Hi,

first of all, be careful, not all replies are correct or even to-the-point

your example does not contain references or pointers; calling a variable "pointer"
does not turn it into a pointer !

The CLR (that is the system underneath several languages including C#)
lets you work with "value types" (such as int and bool, but also struct) and
"reference types" (such as Form and Button).

A local value type (one declared inside a method) is stored on the stack.
If you pass it as a parameter to another method, it gets copied (or at least
behaves as if it were copied), so that method cannot modify your variable.

Things change when you add the "ref" keyword to your parameter list, both
for caller and callee. Now you are really passing a pointer, and the callee
can modify the caller's variable.
If you're familiar with C, it is like adding a * at the caller, and a & at the
callee (but then all the code of the callee needs additional *, not so in C#).

A reference type is different, it IS a pointer to an object, so when you pass it
to some method, that method can do whatever it chooses to do to your object.

Conclusion: if you have bool symbol=true;
and you want to call a method such that it could change symbol, then do:
someMethod(ref symbol);


May I suggest you buy a book on C# and work your way through it.
I am convinced you need to have a reference book at hand at all times when
starting to use a new language.

Good luck!




GeneralRe: Reference as a 'pointer' to a value type [modified] Pin
kildareflare30-Jul-07 9:09
kildareflare30-Jul-07 9:09 
GeneralRe: Reference as a 'pointer' to a value type Pin
Luc Pattyn30-Jul-07 9:12
sitebuilderLuc Pattyn30-Jul-07 9:12 
GeneralRe: Reference as a 'pointer' to a value type Pin
kildareflare30-Jul-07 9:17
kildareflare30-Jul-07 9:17 
GeneralRe: Reference as a 'pointer' to a value type Pin
Cfer8330-Jul-07 9:37
Cfer8330-Jul-07 9:37 
QuestionCheckSignature of SignedXml returns false Pin
amit_k_gupta30-Jul-07 7:37
amit_k_gupta30-Jul-07 7:37 
QuestionXML serialization - Class and Property [modified] Pin
User 665830-Jul-07 7:25
User 665830-Jul-07 7:25 
AnswerRe: XML serialization - Class and Property Pin
Martin#30-Jul-07 8:02
Martin#30-Jul-07 8:02 
GeneralRe: XML serialization - Class and Property Pin
User 665830-Jul-07 8:44
User 665830-Jul-07 8:44 
AnswerRe: XML serialization - Class and Property Pin
BoneSoft30-Jul-07 9:20
BoneSoft30-Jul-07 9:20 
QuestionForm Designer and Dispose() Pin
PhilDanger30-Jul-07 7:14
PhilDanger30-Jul-07 7:14 
QuestionHow Do I Define String Length? Pin
JamesBarnes30-Jul-07 7:05
JamesBarnes30-Jul-07 7:05 
AnswerRe: How Do I Define String Length? Pin
Judah Gabriel Himango30-Jul-07 7:09
sponsorJudah Gabriel Himango30-Jul-07 7:09 
GeneralRe: How Do I Define String Length? Pin
JamesBarnes30-Jul-07 7:18
JamesBarnes30-Jul-07 7:18 
GeneralRe: How Do I Define String Length? Pin
PIEBALDconsult30-Jul-07 10:49
mvePIEBALDconsult30-Jul-07 10:49 
Questionlayouting a hidden control Pin
burn_hh30-Jul-07 6:49
burn_hh30-Jul-07 6:49 
QuestionSQL Database Pin
ankit_mait30-Jul-07 6:40
ankit_mait30-Jul-07 6:40 
AnswerRe: SQL Database Pin
Paul Conrad30-Jul-07 6:43
professionalPaul Conrad30-Jul-07 6:43 

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.