Questions tagged [console.readline]

Reads the next line of characters from the standard input stream.

Console.ReadLine reads input from the console. When the user presses enter, it returns a string. We then resume the program and process the string to determine the next action to take.

114 questions
0
votes
2 answers

Console terminates after Console.Read(), even with Console.ReadLine() at the end

The following code asks for your name and surname. class Program { static void Main(string[] args) { Console.Write("Enter your name: "); string s = Console.ReadLine(); Console.WriteLine("Your name:…
0
votes
1 answer

How to only allow single words to be input using console.readline() in c#?

I have the following code. Console.Clear(); string encodedMessage = ""; Console.WriteLine("Enter a word to encode"); char[] stringtoencode = Console.ReadLine().ToCharArray(); for (int i = 1; i < stringtoencode.Length; i++) { string…
GaryDev
  • 15
  • 8
0
votes
2 answers

How using Console.Read() get two numbers

my question is how to two numbers using Console.Read().When I run the code using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; { class Program { …
Simona
  • 29
  • 2
  • 6
0
votes
1 answer

capture keystroke without blocking

I usually use Console.ReadLine(); to capture a single keystroke. But this function blocks execution and keeps waiting for it to happen. Is it possible, inside a loop, to capture it if it's pressed and continue execution if it's not? The best would…
Hikari
  • 3,797
  • 12
  • 47
  • 77
0
votes
1 answer

How to fix resource leak because of missing EndInvoke call?

I would like to use this solution to call Console.ReadLine() with a timeout: delegate string ReadLineDelegate(); string ReadLine(int timeoutms) { string resultstr = null; ReadLineDelegate d = Console.ReadLine; IAsyncResult result =…
Roland
  • 4,619
  • 7
  • 49
  • 81
0
votes
2 answers

Increase buffer for Console.Readline?

I have a line that is about 1.5kb of text. I want my console app to read it but only the first 255 characters can be pasted in. How do I increase this limit? I am literally reading it using Console.ReadLine() in debug mode under visual studio 2013
user34537
0
votes
1 answer

Console.ReadLine() accept one char and stop prompt

In a console application, I use a Console.Readline() to prompt, It is only use to get an int (1 to 5), However you can add more char than necessary. How could I stop the prompt after record one char in my console please ? You see this underscore…
C0ZEN
  • 894
  • 11
  • 41
0
votes
0 answers

Add a variable to store a user’s first name using console.readLine

I am new to Java, and I would like to know the answer for this question. Why isn't the first line enough to store that value? Thanks. printscreen: https://i.stack.imgur.com/0CjkI.png
0
votes
4 answers

Get highest number from inputs

I need a programm, where I can type in numbers and in the end it gives me the highest number. Why doesn't it work like that? What do I need to change? public class Program { public static void Main() { double[] input = new…
aha364636
  • 365
  • 5
  • 23
0
votes
0 answers

how can i assign a negative value to an integer using console.readline()?

using System; namespace ConsoleApplication1 { class Program { static void Main(string[] args) { int x1, x2, a, b,c,sum; double delta; Console.WriteLine("dati coeficientii ecuatiei de gradul doi…
0
votes
2 answers

c# how to check string is a number when using console.readline

How would I go by checking if there are number values in a string when using console.readline? PlayerNode playerList = new PlayerNode(); for (int x = 1; x <= numPlayers; x++) { Console.WriteLine("What is your name?"); Player Aplayer = new…
tizzyman
  • 9
  • 1
0
votes
2 answers

Integer.parseInt(System.console().readLine() Cannot Handle Characters

Beginner Java enthusiast here. I wanted to take a break from structured practice stuff and start with a blank page, and no help to write something of my own to test myself. I had to learn about console().readLine() as I had not learned how to…
0
votes
1 answer

Looping values into a two-dimensional array with a foreach loop?

So I'm trying to loop values into a two-dimensional array using foreach. I know the code should look something like this. int calc = 0; int[,] userfields = new int[3,3]; foreach (int userinput in userfields) { …
Tatu
  • 153
  • 1
  • 1
  • 9
0
votes
1 answer

How to display UTF-8 characters in RAILS CONSOLE?

I am trying to display UTF-8 characters, in particular characters from the Tamil language, in the Rails Console. Currently, my entries in my MongoDB database are displayed in the Rails console as follows: "_____". On my Rails application, i.e.…
soosap
  • 1,365
  • 2
  • 14
  • 30
0
votes
2 answers

console.readLine() and console.format(): What is meant by arguments referenced by format specifiers?

This question has a follow-up question here. Following this tutorial and compiling the given RegexTestHarness is giving the following errors on console.readLine(String) and console.Format(String), respectively: The method readLine() in the type…
Solace
  • 8,612
  • 22
  • 95
  • 183