Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. Switch, case?

Switch, case?

Scheduled Pinned Locked Moved C#
question
5 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • N Offline
    N Offline
    nhqlbaislwfiikqraqnm
    wrote on last edited by
    #1

    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()); }

    0 E 2 Replies Last reply
    0
    • N nhqlbaislwfiikqraqnm

      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()); }

      0 Offline
      0 Offline
      0x3c0
      wrote on last edited by
      #2

      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

      N 1 Reply Last reply
      0
      • N nhqlbaislwfiikqraqnm

        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()); }

        E Offline
        E Offline
        Ennis Ray Lynch Jr
        wrote on last edited by
        #3

        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

        N 1 Reply Last reply
        0
        • 0 0x3c0

          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

          N Offline
          N Offline
          nhqlbaislwfiikqraqnm
          wrote on last edited by
          #4

          Okay thank you! then i will make it with if!

          1 Reply Last reply
          0
          • E Ennis Ray Lynch Jr

            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

            N Offline
            N Offline
            nhqlbaislwfiikqraqnm
            wrote on last edited by
            #5

            right that can i delet

            1 Reply Last reply
            0
            Reply
            • Reply as topic
            Log in to reply
            • Oldest to Newest
            • Newest to Oldest
            • Most Votes


            • Login

            • Don't have an account? Register

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • World
            • Users
            • Groups