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

  • Home
  • SEARCH
  • 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 8775413
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T18:47:35+00:00 2026-06-13T18:47:35+00:00

Console.WriteLine(Enter the cost of the item); string input = Console.ReadLine(); double price = Convert.ToDouble(input);

  • 0
Console.WriteLine("Enter the cost of the item");                           
string input = Console.ReadLine();
double price = Convert.ToDouble(input);

Hello, I want the keyboard buttons, A-Z, brackets, question mark, etc to be disabled. I want it so if you type it in, it will not show up in the Console. I only want the numbers 1-9 to show up. This is in C# Console application. Thanks for the help!

  • 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-06-13T18:47:36+00:00Added an answer on June 13, 2026 at 6:47 pm

    try this code snippet

    string _val = "";
    Console.Write("Enter your value: ");
    ConsoleKeyInfo key;
    
    do
    {
        key = Console.ReadKey(true);
        if (key.Key != ConsoleKey.Backspace)
        {
            double val = 0;
            bool _x = double.TryParse(key.KeyChar.ToString(), out val);
            if (_x)
            {
                _val += key.KeyChar;
                Console.Write(key.KeyChar);
            }
        }
        else
        {
            if (key.Key == ConsoleKey.Backspace && _val.Length > 0)
            {
                _val = _val.Substring(0, (_val.Length - 1));
                Console.Write("\b \b");
            }
        }
    }
    // Stops Receving Keys Once Enter is Pressed
    while (key.Key != ConsoleKey.Enter);
    
    Console.WriteLine();
    Console.WriteLine("The Value You entered is : " + _val);
    Console.ReadKey();
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Console.WriteLine(Enter a double number); string numberInput = Console.ReadLine(); double number = Double.Parse(numberInput) My question
Person tempPerson; Console.WriteLine(Enter the name of this new person.); tempPerson.Name = Convert.ToString(Console.ReadLine()); Console.WriteLine(Now their
public DateTime EnterDeparture() { DateTime EnterDeparture = new DateTime(); Console.WriteLine(Enter Year:); EnterDeparture.AddYears(int.Parse(Console.ReadLine())); return EnterDeparture;
public DateTime EnterDeparture() { Console.WriteLine(Enter Year:); return new DateTime().AddYears(int.Parse(Console.ReadLine())); } // This will return
Console.WriteLine(Enter the page that you would like to set the bookmark on: ); SetBookmarkPage(int.Parse(Console.ReadLine));
Console application: Dim myno As Integer = 1010 Console.WriteLine(Convert.ToString(myno)) Dim sw As New StreamWriter(filename.txt,
string s = string; Console.WriteLine(s[1]); // returns t char[] chars = s.ToCharArray(); Console.WriteLine(chars[1]); //
Server side code: static void Main(string[] args) { static Socket sck; Console.WriteLine(Server Started...); sck
class Program { static void Main() { Console.WriteLine(enter main method); Console.WriteLine(Foo.X); Console.ReadKey(); } }
Why does Console.WriteLine work from multiple threads?

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.