I. Differences between console. Write () and console. writeline ()
The former outputs no line breaks.
Ii. Differences between console. Read () and console. Readline ()
1 'console. read () console. the Readline () method reads information from the keyboard. The only difference is the console. the read () method is used to obtain the ASCII value of any user input value (which can be any alphanumeric value. console. what about Readline? Stores the obtained data in a string variable.
2 'console. Read () indicates reading strings from the keyboard without line breaks. Console. Readline () indicates reading strings from the keyboard and wrapping them.
3. Accept multiple data inputs at the same time
Solve the problem through system functions using Arrays: for example:
Example 1: create a one-dimensional integer array, initialize the array by receiving the 10 numbers entered by the user, and print them in reverse order.
Implemented Using console. Readline () and string Separator
Static void main (string [] ARGs)
{
Console. writeline ("Enter ten numbers and separate them with spaces :");
String string1 =
Console. Readline ();
String [] string2 = system. Text. regularexpressions. RegEx. Split (string1, @ "[] + ");
String [] result = newstring [10];
For (INT I = 0; I <10; I ++)
{
Result [I] = (string2 [10-I-1]);
Console. Write (result [I] + "");
}
}
I. Differences between console. Write () and console. writeline ()
The former outputs no line breaks.
Ii. Differences between console. Read () and console. Readline ()
1 'console. read () console. the Readline () method reads information from the keyboard. The only difference is the console. the read () method is used to obtain the ASCII value of any user input value (which can be any alphanumeric value. console. what about Readline? Stores the obtained data in a string variable.
2 'console. Read () indicates reading strings from the keyboard without line breaks. Console. Readline () indicates reading strings from the keyboard and wrapping them.
3. Accept multiple data inputs at the same time
Solve the problem through system functions using Arrays: for example:
Example 1: create a one-dimensional integer array, initialize the array by receiving the 10 numbers entered by the user, and print them in reverse order.
Implemented Using console. Readline () and string Separator
Static void main (string [] ARGs)
{
Console. writeline ("Enter ten numbers and separate them with spaces :");
String string1 =
Console. Readline ();
String [] string2 = system. Text. regularexpressions. RegEx. Split (string1, @ "[] + ");
String [] result = newstring [10];
For (INT I = 0; I <10; I ++)
{
Result [I] = (string2 [10-I-1]);
Console. Write (result [I] + "");
}
}