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. Simple case statement looking for Enter key

Simple case statement looking for Enter key

Scheduled Pinned Locked Moved C#
helptutorialquestion
3 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.
  • B Offline
    B Offline
    Brad Wick
    wrote on last edited by
    #1

    I have the following case statement where I am looking for a enter key being pushed to be in the suffix. I need this to be a enter but I can not seem to figure out how to add the char(13) as I can not make it into a string and fit into the const setting. Can someone help me with this?

    string keyAscii = e.KeyChar.ToString();
    const string Prefix = "|~";
    const string Sufix = "";
    
    switch(keyAscii)
    {
        case Prefix:
            // Code
            break;
        case Sufix:
            //Code
            break;
        default:
            //Code
            break;
    }
    
    W P 2 Replies Last reply
    0
    • B Brad Wick

      I have the following case statement where I am looking for a enter key being pushed to be in the suffix. I need this to be a enter but I can not seem to figure out how to add the char(13) as I can not make it into a string and fit into the const setting. Can someone help me with this?

      string keyAscii = e.KeyChar.ToString();
      const string Prefix = "|~";
      const string Sufix = "";
      
      switch(keyAscii)
      {
          case Prefix:
              // Code
              break;
          case Sufix:
              //Code
              break;
          default:
              //Code
              break;
      }
      
      W Offline
      W Offline
      Wendelius
      wrote on last edited by
      #2

      Perhaps this will help: Keys Enumeration[^]

      The need to optimize rises from a bad design. My articles[^]

      1 Reply Last reply
      0
      • B Brad Wick

        I have the following case statement where I am looking for a enter key being pushed to be in the suffix. I need this to be a enter but I can not seem to figure out how to add the char(13) as I can not make it into a string and fit into the const setting. Can someone help me with this?

        string keyAscii = e.KeyChar.ToString();
        const string Prefix = "|~";
        const string Sufix = "";
        
        switch(keyAscii)
        {
            case Prefix:
                // Code
                break;
            case Sufix:
                //Code
                break;
            default:
                //Code
                break;
        }
        
        P Offline
        P Offline
        PIEBALDconsult
        wrote on last edited by
        #3

        Or "\n" ?

        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