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
1
vote
1 answer

Why can't you convert Console.ReadLine to int trough Convert.ToInt

so I was just starting to code and found out that this example right here doesn't work, but with int.TryParse() it would work. Otherwise with Convert.Byte() it works too. What is the background of that? using System; namespace timezones { class…
1
vote
3 answers

False value from User Input

I am trying to save the value i get through Console.Read() in an Integer, but whatever i type in my keyboard, the console always gives out 13. I tried to copy an example code, which definitly has to work, but im still only getting 13 as value. using…
1
vote
0 answers

how to mask a password and show the cursor movements in commandline in java?

I am trying to run a java application in console. Here is the code for username and password I used console.readPassword() and when I type my password in the console the cursor appears on the same same starting line and it remains in the same…
D V
  • 211
  • 6
  • 13
1
vote
2 answers

How to input data through console in node.js?

Although similar questions have already appeared, following theirs instructions I obtain an error. So my code is as follows var readline = require('readline').createInterface({ input: process.stdin, output: process.stdout }); var name; …
zorro47
  • 221
  • 1
  • 11
1
vote
1 answer

How do i put only the first string of a line in an array while using console.readline

I need to only get the first Numbers of an input line from the console. If the console gives input being: 20 //this is some input text Then I need my array to be only filled with the number 20 while still using console.readline.
1
vote
1 answer

Learning C#, wrote faulty program, need help as to why it's not function how I want it to

I'm new to coding and wrote this little console reading program to try and make sense of arrays, methods, etc. I know my code is very faulty and probably not properly written (by book). I would like some help on how to fix my program though, it has…
1
vote
2 answers

Can you set a variable to console.ReadLIne()?

I am new to programming here. This is a question that i have been mulling over. Can you set a variable to Console.ReadLine() in c# and then call the variable instead of typing Console.ReadLine() everytime? For example: //Set Variable var read =…
soso
  • 311
  • 1
  • 4
  • 13
1
vote
3 answers

Ways to avoid crashes when using user input (int) as a link for several functions?

I can't find a clear answer on how to assign user input to be usable elsewhere as an integer without crashing the program from invalid key inputs. I'm also unsure if setting the input to be an integer is a good idea as it's the only method I know.…
1
vote
2 answers

Getting "Input string was not in a correct format." on SECOND step thru loop

Code enclosed below. I am coding a menu where the user types a number to select a menu option. It also is enclosed in a while loop, so the user can repeat the menu over and over again. It works perfectly on the first loop thru, but on the second it…
Will
  • 103
  • 12
1
vote
2 answers

Exiting 'do while ReadLine' loop not working

I am trying to learn C# as I have little experience there. I wanted to set up a Console.Readline in a Do While loop so I can read in an unknown amount of values into an array. It never exits so the comparison in the while is not working. What is…
user4347421
  • 31
  • 1
  • 3
1
vote
2 answers

switch case ignores Console.ReadLine()

I am helping a friend with some beginner c#, and we have run into a weird problem. The læn = Console.ReadLine() on line 31 is being skipped. This causes the .Parse on line 32 to throw an error. If we put an extra læn = Console.ReadLine() in after…
1
vote
1 answer

No Console found. How to get the console for my JVM?

This is a follow-up question to this. I asked this question yesterday, and although it is not resolved yet, I tried to make some silly changes to the code to just make it compile once (replacing console.format() statements by System.out.print…
Solace
  • 8,612
  • 22
  • 95
  • 183
1
vote
3 answers

Reading three inputs from the user using Console.ReadLine()

Is this the correct way to do it, since I'm new to C# Console.WriteLine("please enter m,y,n: \n"); double month, year, numberOfMonths = Convert.ToDouble(Console.ReadLine());
Abner_CV
  • 25
  • 1
  • 2
  • 10
1
vote
3 answers

Console.Read() doesn't allow me to input anything the second time

I'm solving a problem about comparing two floating-point numbers and I want to let the user input desired values. So I wrote the following code: Console.WriteLine("Enter first number: "); double num1 = Console.Read(); …
Boyan Kushlev
  • 1,043
  • 1
  • 18
  • 35
1
vote
3 answers

Console.ReadLine() not keeping console open in C#

I'm learning C# (VS 2012 Professional) and in the following example, the console window isn't staying open even though the Console.ReadLine() method is the last instruction in the code block: using System; using System.Collections.Generic; using…
user1063287
  • 10,265
  • 25
  • 122
  • 218