Hi,
I am new to this forum and C#. I have following code.
When I executed this code,
1) Console window printed the following text: "Enter a character"
2) I entered 'a' and pressed Enter key
3) Console window displayed 97 and then printed the text: "Enter a string of characters"
4) I entered 'abcd' and pressed Enter key
5) I expected the text 'abcd" should be printed. However the console window vanished.
Any idea, why this happens?
I am new to this forum and C#. I have following code.
C#:
[FONT=Consolas][SIZE=2][COLOR=#2b91af][FONT=Consolas][SIZE=2][COLOR=#2b91af][FONT=Consolas][SIZE=2][COLOR=#2b91af]Console.WriteLine("Enter a character");
[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Consolas][SIZE=2][COLOR=#0000ff][FONT=Consolas][SIZE=2][COLOR=#0000ff][FONT=Consolas][SIZE=2][COLOR=#0000ff]int int1 = Console.Read();
Console.WriteLine(int1);
Console.WriteLine("Enter a string of characters");
string string1 = Console.ReadLine();
Console.WriteLine(string1);
Console.ReadLine();
[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT]
When I executed this code,
1) Console window printed the following text: "Enter a character"
2) I entered 'a' and pressed Enter key
3) Console window displayed 97 and then printed the text: "Enter a string of characters"
4) I entered 'abcd' and pressed Enter key
5) I expected the text 'abcd" should be printed. However the console window vanished.
Any idea, why this happens?