Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Console.WriteLine() Making a a sound when Convert.ToChar(7) is put in it

Tags:

c#

.net

console

When I run the code

Console.WriteLine(Convert.ToChar(Convert.ToByte(7)))

My computer makes a noise, I have confirmed this to work on a Windows 7 computer as well, I am using windows 10. My assumption is that it either has to do with how Unicode or the console handles this character but I'm not really certain. Any help understanding this would be greatly appreciated.

like image 425
Nick B Avatar asked Feb 12 '18 11:02

Nick B


People also ask

What is console WriteLine () in C#?

WriteLine(String, Object, Object) Writes the text representation of the specified objects, followed by the current line terminator, to the standard output stream using the specified format information. WriteLine(String)

What is console WriteLine () good for?

Write is used to print data without printing the new line, while Console. WriteLine is used to print data along with printing the new line.

How do I get console WriteLine output in Visual Studio?

In Visual Studio uppermost menu choose Debug > Windows > Output. It shows all Console. WriteLine("Debug MyVariable: " + MyVariable) when you get to them.

What is console WriteLine in programming?

The Console. WriteLine() method prints a new line after the text or a value. The Console. Write() method only prints the text or value without a new line.


1 Answers

char 7 is the BELL character. In early days, you could make the motherboard make a chime with just a key on your keyboard or a character put on the terminal.

When you output that character using a command line program, it plays that sound.

like image 112
Patrick Hofman Avatar answered Sep 19 '22 03:09

Patrick Hofman