Switch, case?
-
Hello! How can i wirte this code into a switch an case? switch(get)
if (get.Contains("rHerunterfahren")) { string[] get_Split = get.Split('~'); int zeit = Convert.ToInt32(get_Split[1]); System.Diagnostics.Process.Start("shutdown", "-s -t " + zeit.ToString()); }
-
Hello! How can i wirte this code into a switch an case? switch(get)
if (get.Contains("rHerunterfahren")) { string[] get_Split = get.Split('~'); int zeit = Convert.ToInt32(get_Split[1]); System.Diagnostics.Process.Start("shutdown", "-s -t " + zeit.ToString()); }
You can't. Or rather, you can, but it'll make the code even more complicated. A switch case tests the switch statement and provides multiple paths of execution. Yours only has two - true and false. Incidentally, if that's related to the code you last posted, your design is a little off. Sending commands in plain text over a stream isn't the best way to go about remote-controlling a computer.
Between the motion And the act Falls the Shadow
-
Hello! How can i wirte this code into a switch an case? switch(get)
if (get.Contains("rHerunterfahren")) { string[] get_Split = get.Split('~'); int zeit = Convert.ToInt32(get_Split[1]); System.Diagnostics.Process.Start("shutdown", "-s -t " + zeit.ToString()); }
If I may question your logic for a second ... If get_Split is an array of strings why not
System.Diagnostics.Process.Start("shutdown", "-s -t " + get_Split[1]);
? The parse to int and then converting to string seems a little silly in context.
Need custom software developed? I do custom programming based primarily on MS tools with an emphasis on C# development and consulting. A man said to the universe: "Sir I exist!" "However," replied the universe, "The fact has not created in me A sense of obligation." --Stephen Crane
-
You can't. Or rather, you can, but it'll make the code even more complicated. A switch case tests the switch statement and provides multiple paths of execution. Yours only has two - true and false. Incidentally, if that's related to the code you last posted, your design is a little off. Sending commands in plain text over a stream isn't the best way to go about remote-controlling a computer.
Between the motion And the act Falls the Shadow
Okay thank you! then i will make it with if!
-
If I may question your logic for a second ... If get_Split is an array of strings why not
System.Diagnostics.Process.Start("shutdown", "-s -t " + get_Split[1]);
? The parse to int and then converting to string seems a little silly in context.
Need custom software developed? I do custom programming based primarily on MS tools with an emphasis on C# development and consulting. A man said to the universe: "Sir I exist!" "However," replied the universe, "The fact has not created in me A sense of obligation." --Stephen Crane
right that can i delet