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.Read with int

I was studying c# one and a half ear ago. And I forgot a lot. Now I want to study it again. I wanted to do int answer; Console.WriteLine("What is the answer?"); answer = Console.Read(); if(answer == 1) { …
Vane4ka
  • 3
  • 2
0
votes
1 answer

Can't input data with Console.ReadLine

I'm trainning in C# alone for this moment, and encounter my first problem. I use VSCode as IDE. What I Am Try To Do Create two functions, the first, data like name and return it. the second return full name. All in one in a class. What I Do From…
Reuno92
  • 57
  • 1
  • 1
  • 7
0
votes
0 answers

CS8600 Error while using the ReadLine() command

CS8600 Error while using the ReadLine() command; Code: namespace Something{ class UserInputEg{ static void Main(string[] args){ string input = Console.ReadLine(); Console.WriteLine(input); …
0
votes
2 answers

How do I get readline to return the fields of a Class?

I am very new/ a beginner to coding. I'm using c# 6.0 in Microsoft Visual studio 2022. I'm trying to create some sort of search function, but perhaps there is a better way to do it. I created a class(didn't include all of the code bc of space) and…
0
votes
1 answer

Why am getting red line under the Console.ReadLine() method in C# even when storing the user input in string type ?PS. red line removed using var?

Console.WriteLine("Enter arguments"); string input = Console.ReadLine();// red line under Console.ReadLine Console.WriteLine("Arguments at run-time " + input); /* I want to show the user input in string through my Console.WriteLine method and I…
0
votes
1 answer

How can I make rl (or prompts) return the value of what the user inputs

How can I get rl.question to return the value that the user inputs, my code looks like this: const readline = require('readline'); const { stdin: input, stdout: output } = require('process'); const rl = readline.createInterface({ input,…
Arin Bryan
  • 29
  • 1
  • 3
0
votes
1 answer

.NET fiddle not letting me write in console

NOTE: I have figured out that this only affects .NET fiddle if you are using .NET 6. If you aren't using .NET 6 it works fine. Whenever I use the Console.WriteLine() function on .NET fiddle, it doesn't let me interact with the console. I'm new at…
0
votes
1 answer

validate readline input (CLI) inside for loop

Input validation above loop works just fine, but not working in loop. Input should not allow: string and negative numbers. Any workaround to do this or just using inside loop is not a go? Yes, I know the maximum entered number can be checked in…
Goaul
  • 943
  • 11
  • 13
0
votes
0 answers

Unable to run Async Method without Console.ReadLine() Or Console.ReadKey()

I have my main method calling another method. Everything works fine as long as I use Console.Readline() or Console.ReadKey(). The minute I remove it, the project is finishing without doing completely what it is supposed to do. private static void…
Vinny
  • 461
  • 1
  • 5
  • 18
0
votes
1 answer

Message Handler Stops Seeing Responses?

As a workaround for a dumb issue, I have a separate application do my SharePoint file syncing that I launch as a separate process and communicate via WriteLine and ReadLine. After the third Sync command, it seems the Process executes it (as…
CodeMonkey
  • 1,795
  • 3
  • 16
  • 46
0
votes
0 answers

Visual Studio Community Version doesn't let me interact the 'Output' console

I have just installed VS Community Edition, and tried to run simple I/O code, but vs just skips the part where I have to input some informations as user: using System.Collections.Generic; using System.Linq; using System.Threading.Tasks; using…
Legendary
  • 1
  • 1
0
votes
1 answer

List of only nummbers, but I need to give it out as a list

I Have to make a list of nummbers, but my conde does not work. I am new at this, that is why I would like to ask if someone could tell me how to do it [I Have to make a list of nummbers, but my conde does not work. I am new at this, that is why…
0
votes
1 answer

Error detected trying to receive input as an integer in C#

I am trying to make a simple program where the user tries to guess numbers between 1 and 25 until they guess the right one. I am trying to make the input received as an integer so that I can use greater than and less than signs. When I use the…
0
votes
2 answers

Using Console.ReadLine().Split() to fill a string array in a loop

I have the following very basic code: static void Main(string[] args) { int n = Convert.ToInt32(Console.ReadLine()); for (int i = 0; i < n*3; i++) { string[] numbers = Console.ReadLine().Split(); Console.WriteLine(); …
TheRealDax
  • 5
  • 1
  • 3
0
votes
2 answers

Error says that it can't transform string into int

string num; num = Console.ReadLine(); Console.WriteLine(num); switch (num) {case 1: Console.WriteLine(one); I'm trying to do a c# project where you type a number from 1 to 100 and…