Current location - Plastic Surgery and Aesthetics Network - Plastic surgery and medical aesthetics - What number does console.read () take in C#, and how to convert the character type into integer or floating-point number?
What number does console.read () take in C#, and how to convert the character type into integer or floating-point number?
Console.read () reads a character.

Console. ReadLine () reads a string.

Console. ReadKey () also reads a character. The difference between it and Read () is that after entering a character on the console, Key () will be executed automatically, while read () must be executed after entering a carriage return.

Example:

I input: abcd enter on the screen.

Read() - a

ReadLine() - abcd

ReadKey()-After entering a, you get one.

The types obtained by these three methods are all string types.

This is basically the same as Write() WriteLine ()

The output is of string type.

Although you can output int I = 2;; WriteLine(I);

In fact, the process of execution is to first convert I into String type (i.ToString ()) and then output it to the console.

You got it?