Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6070483
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T09:56:19+00:00 2026-05-23T09:56:19+00:00

How can I convert a Key (Key in KeyEventArgs) to a string. For example,

  • 0

How can I convert a Key (Key in KeyEventArgs) to a string.

For example, if the user enter “-” :

e.Key.ToString() = "Subtract"
new KeyConverter().ConvertToString(e.Key) = "Subtract"

What I want is to get “-” for result, not “Substract”…

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T09:56:20+00:00Added an answer on May 23, 2026 at 9:56 am

    Use a Dictionary<TKey, TValue>:

    Class-level:

    private readonly Dictionary<string, string> operations = new Dictionary<string, string>;
    
    public ClassName() {
        // put in constructor...
        operations.Add("Subtract", "-");
        // etc.
    }
    

    In your method, just use operations[e.Key.ToString()] instead.

    Edit: Actually, for more efficiency:

    private readonly Dictionary<System.Windows.Input.Key, char> operations = new Dictionary<System.Windows.Input.Key, char>;
    
    public ClassName() {
        // put in constructor...
        operations.Add(System.Windows.Input.Key.Subtract, '-');
        // etc.
    }
    

    In your method, just use operations[e.Key] instead.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

How can I export the private key embedded in an .cer file and convert
How can I convert RSAPublicKey into something readable (public key sharing reasons) and then
Does Cocoa provide a built-in method to convert a key string into a properly-formatted
How can I convert this RSA public key: 109120132967399429278860960508995541528237502902798129123468757937266291492576446330739696001110 6039072308886100726558188253585034290 57592827629436413108566029093628 2126359538366865626758497206207862794310902180176810615217550567108238764764442605581471797071 19674283982419152118103759076030616683978566631413 to
How to convert pkcs8 key file to DER format, to get Private and Public
I have a value of key in file. How I can convert this value
How can I convert the string to datetime using linq to entities .... I
You can convert a negative number to positive like this: int myInt = System.Math.Abs(-5);
we can convert character to an integer equivalent to the ASCII value of the
How i can convert to c# code files to html files?Is there any generation

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.