How can I add music to C#? | Sololearn: Learn to code for FREE!
¡Nuevo curso! ¡Todo programador debería aprender IA Generativa!
Prueba una lección gratuita
0

How can I add music to C#?

My teacher tell me if I add music to a C# program (console) he'll give me extra points in my exam. Please help me with the code.

3rd Oct 2019, 11:25 PM
Saúl
Saúl - avatar
6 Respuestas
+ 3
You will want to use System.Console.Beep(int frequency, int duration) https://docs.microsoft.com/en-us/dotnet/api/system.console.beep?view=netframework-4.8#System_Console_Beep_System_Int32_System_Int32_ https://www.geeksforgeeks.org/c-sharp-how-to-play-user-modified-beep-sound-through-console/amp/ Here are some examples I found online. I would avoid using these as your teacher probably found the same examples as well. 😉 But, these should give you a good idea of what's involved. Tetris (with theme song) in the C# console. https://gist.github.com/erineccleston/0d65a78e9df88d68a13a421d2a298f10 SUPER MARIO SONG USING CONSOLE.BEEP() https://hashtagakash.wordpress.com/2014/01/22/182/ https://code.sololearn.com/cN9GCp8sxk8L/
4th Oct 2019, 12:32 AM
David Carroll
David Carroll - avatar
+ 5
TheCoder | I Specialise in C# I'm confused about your response and the down votes. 🤔 There's nothing "bad about preparing him for the future..." so to speak, nor did I mean you any offense. I was simply clarifying that my answer was a direct response to the criteria specified in the question. I certainly wasn't making a case for creating songs using Console.Beep() over a more sophisticated solution you were pointing out. That said, Saúl is free to submit either solution to his teacher. However, if the criteria was limited to a Console App, the WPF solution might not earn the extra points he was hoping for on his exam. 🤷‍♂️ If this response is somehow received as offensive, please know that wasn't my intent.
5th Oct 2019, 6:16 AM
David Carroll
David Carroll - avatar
+ 3
TheCoder | I Specialise in C# If the challenge applies to WPF, then, your suggestion would be great. 😉👌 However, as I understand it from the posted question, the challenge from the teacher was to add sound to a Console Application written in C#. In that case, I believe the option I provided is the only one that will work. 🤷‍♂️🤓
4th Oct 2019, 6:44 AM
David Carroll
David Carroll - avatar
+ 1
What do you have so far ,in code? How much C# do you know?
4th Oct 2019, 12:00 AM
Manual
Manual - avatar
+ 1
I don't have a big experience, I'm still learning
4th Oct 2019, 1:25 AM
Saúl
Saúl - avatar
+ 1
Thanks David Carroll
4th Oct 2019, 1:25 AM
Saúl
Saúl - avatar