Click here to Skip to main content
15,888,190 members
Home / Discussions / C#
   

C#

 
GeneralRe: TCP connection to specific client Pin
kruegs3518-Jun-14 5:57
kruegs3518-Jun-14 5:57 
AnswerRe: TCP connection to specific client Pin
ZurdoDev18-Jun-14 8:29
professionalZurdoDev18-Jun-14 8:29 
AnswerRe: TCP connection to specific client Pin
jschell18-Jun-14 11:15
jschell18-Jun-14 11:15 
QuestionCorrect Syntax; No Result? Pin
Zachery Hysong17-Jun-14 7:50
Zachery Hysong17-Jun-14 7:50 
AnswerRe: Correct Syntax; No Result? Pin
Eddy Vluggen17-Jun-14 8:05
professionalEddy Vluggen17-Jun-14 8:05 
GeneralRe: Correct Syntax; No Result? Pin
Zachery Hysong17-Jun-14 8:22
Zachery Hysong17-Jun-14 8:22 
GeneralRe: Correct Syntax; No Result? Pin
Eddy Vluggen17-Jun-14 8:50
professionalEddy Vluggen17-Jun-14 8:50 
AnswerRe: Correct Syntax; No Result? Pin
OriginalGriff17-Jun-14 8:21
mveOriginalGriff17-Jun-14 8:21 
Look at the code:
C#
public void optionCheck(TextBox txt, string str)

That means that both txt and str are Value parameters - the default - which means that the value of the variable is copied and the copy passed to the method when it is called - so any changes to the value of the variable affect the copy, and not the original. When the method ends, the modified value is thrown away.
This is exactly the normal behaviour - and it is exactly what you want to happen!
Take an example, and think about what would happen if what you expected to happen did:
C#
public void Change(int i)
   {
   i = i + 2;
   }
Now, that's fine when you call it like this:
C#
int iOriginal = 6;
Change(iOriginal);
Console.WriteLine(iOriginal);
You will be expecting to get "8" printed.
But...what happens if you do this:
C#
Change(6);
Console.WriteLine(6);
The last thing you want is to get "8" printed! Laugh | :laugh:

But that is exactly what "should" happen - you passed in a value, the method changed it and tit affected the outside world. The method doesn't know - and can't check - that you are passing in a value that can be variable!

You can do what you want, but you have to tell teh system that that is exactly what you want to happen:
C#
public void optionCheck(TextBox txt, ref string str)
{
    if (txt.Text == "0")
    {
        str = "+++";
    }
    else
    {
        str = "---";
    }
}
And call it like this:
C#
optionCheck(txtDoorsSafety1, ref strDoorsOption1);
But then you can't call it with a string constant because will get a compilation error, and the system now knows you want to change a constant, and you can't do that!

Make sense?
Those who fail to learn history are doomed to repeat it. --- George Santayana (December 16, 1863 – September 26, 1952)
Those who fail to clear history are doomed to explain it. --- OriginalGriff (February 24, 1959 – ∞)

GeneralRe: Correct Syntax; No Result? Pin
Zachery Hysong17-Jun-14 8:23
Zachery Hysong17-Jun-14 8:23 
GeneralRe: Correct Syntax; No Result? Pin
OriginalGriff17-Jun-14 8:29
mveOriginalGriff17-Jun-14 8:29 
AnswerRe: Correct Syntax; No Result? Pin
Richard Deeming17-Jun-14 8:26
mveRichard Deeming17-Jun-14 8:26 
QuestionHow do I get a list of all windows user groups Pin
sneezesnoeze16-Jun-14 22:48
sneezesnoeze16-Jun-14 22:48 
AnswerRe: How do I get a list of all windows user groups Pin
Eddy Vluggen17-Jun-14 3:03
professionalEddy Vluggen17-Jun-14 3:03 
GeneralRe: How do I get a list of all windows user groups Pin
sneezesnoeze17-Jun-14 8:02
sneezesnoeze17-Jun-14 8:02 
GeneralRe: How do I get a list of all windows user groups Pin
Eddy Vluggen17-Jun-14 8:08
professionalEddy Vluggen17-Jun-14 8:08 
GeneralRe: How do I get a list of all windows user groups Pin
sneezesnoeze17-Jun-14 10:59
sneezesnoeze17-Jun-14 10:59 
GeneralRe: How do I get a list of all windows user groups Pin
Eddy Vluggen17-Jun-14 11:09
professionalEddy Vluggen17-Jun-14 11:09 
GeneralRe: How do I get a list of all windows user groups Pin
Pete O'Hanlon17-Jun-14 11:47
mvePete O'Hanlon17-Jun-14 11:47 
AnswerRe: How do I get a list of all windows user groups Pin
Yonatan Arbel20-Jun-14 2:51
Yonatan Arbel20-Jun-14 2:51 
AnswerRe: How do I get a list of all windows user groups Pin
Nathan Minier20-Jun-14 3:08
professionalNathan Minier20-Jun-14 3:08 
QuestionC# Windows Forms App Pin
Zeyad Jalil16-Jun-14 19:33
professionalZeyad Jalil16-Jun-14 19:33 
AnswerRe: C# Windows Forms App Pin
Eddy Vluggen17-Jun-14 7:15
professionalEddy Vluggen17-Jun-14 7:15 
AnswerRe: C# Windows Forms App Pin
Swinkaran17-Jun-14 13:39
professionalSwinkaran17-Jun-14 13:39 
Question[Wp8.1] How to save the RenderTargetBitmap to png? Pin
Lãng Khách15-Jun-14 23:08
Lãng Khách15-Jun-14 23:08 
AnswerRe: [Wp8.1] How to save the RenderTargetBitmap to png? Pin
BobJanova16-Jun-14 0:34
BobJanova16-Jun-14 0:34 

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.