Hello AMP,
when u pass rxHeader variable into your method it passed by value,
it means that you have the local copy of your rxHeader variable inside comRxHeader
method, not the class variable
Any changes of your local variable inside method don't reference to the class
variable.
When u exit the method, your local variable GCed and class variable is set
to the previous value, that is 0 in your case.
To change this behaviour use "ref" keyword before your function param, like
comRxHeader(ref rxHeader, rxNum, (timeout * prolongFactor))
in that case all changes to rxHeader inside method will reference to you
class variable
AHello,
AI have a Form level variable:
Apublic partial class Form1 : Form
A{
Abyte rxHeader = 0;..............................
AThat gets passed from one function to another:
Aif (comRxHeader(rxHeader, rxNum, (timeout * prolongFactor)) ==
A0)..........// rxHeader is 0 when it leaves here
AcomRxHeader changes it to 144. It stays at 144 all through the
Afunction, but when it gets back to the sending function(comTxRx) it
Ais
A0 again, but there is nothing to change it back to 0.
AWhat am I doing wrong?
AThanks
AMike
---
WBR,
Michael Nemtsev :: blog:
http://spaces.live.com/laflour
"At times one remains faithful to a cause only because its opponents do not
cease to be insipid." (c) Friedrich Nietzsche