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
votes
4 answers

Multiple IFs won't work

I'm creating a Desktop application (console) for Windows, using C#. This is my code: namespace myapp { class Program { static void Main(string[] args) { Console.WriteLine("Hello!"); …
-1
votes
1 answer

Receiving totally different answers when using cast and parse with float

I am learning to code with C# since I like what the language has to offer and in a learning exercise I was doing I came up with a problem. The gist of the exercise was to learn declaring variables, using them and displaying them. My code, which…
Eduardo
  • 23
  • 1
  • 6
-1
votes
2 answers

Console.ReadLine() not exiting Program in c#

I have an assignment where I have to create code to display factors and whether a number is a perfect and/or prime number. I think I have all the code right to run my program, but when I get to the last line (Console.ReadLine()) I expect to hit…
user7211305
-2
votes
1 answer

convert to decimal in C#

When I use Console.ReadLine(), I input numbers without decimal(2000). Afterwards I need to show this number like decimal number(2000.00), using Console.WriteLine().How to do…
-2
votes
2 answers

The method Console.Read() don't returns a string

When I declare a variable "string x = Console.Read();" the message is shown: "Cannot implicitly convert type 'int' to 'string'". To test this, I made the console show the value I wrote in the input. I typed 5 in the input but the console showed me…
Danilo
  • 1
  • 1
-2
votes
2 answers

C#. Console.ReadLine() for two different obejcts

I'm learning C# and very new to this topic. Currently, I'm working on a small console app (just doing tasks to strengthen my knowledge) Battleship game. I want to assign two names: Player 1 and Player 2. Question is: Can I use one reader instead of…
-4
votes
2 answers

c# Console.WriteLine();

In C#, after I write Console.WriteLine() and I'm asked to enter several values, can I get them all in one method? For example: double a, b, c = 0; Console.WriteLine("please enter the values of:\n a value:\n b value: \n c value:"); thanks for the…
-4
votes
1 answer

VB.NET Console.ReadLine() min length?

How would you be able to read less than the standard 254 characters from the console, in VB.NET with Console.ReadLine()? I have tried using Console.ReadKey(): Dim A As String = "" Dim B As Char For i = 0 To 10 B = Console.ReadKey().KeyChar …
Hguin
  • 11
  • 1
  • 7
-5
votes
1 answer

Why does Read interfere with ReadLine?

I wrote a very basic program in C#. However, I don't understand the behavior of the executed program. Why does Read() interfere with ReadLine()? int str = Console.Read(); string str1 =…
abdeaitali
  • 155
  • 1
  • 2
  • 7
1 2 3 4 5 6 7
8