如何在 C# 中通过控制台播放哔声?


若要通过控制台播放哔声,代码如下 -

示例

 在线演示

using System;
public class Demo {
   public static void Main(String[] args){
      Console.WriteLine("Displaying standard output stream...");
      Console.WriteLine("Standard Output Stream = "+Console.Out);
      Console.WriteLine("Beep sound through Console");
      Console.Beep();
   }
}

输出

这将产生以下输出 -

Displaying standard output stream...
Standard Output Stream = System.IO.TextWriter+SyncTextWriter
Beep sound through Console

示例

现在让我们看另一个示例 -

 在线演示

using System;
public class Demo {
   public static void Main(String[] args){
      Console.WriteLine("Displaying standard output stream...");
      Console.WriteLine("Standard Output Stream = "+Console.Out);
      Console.WriteLine("Beep sound through Console");
      Console.Beep();
      Console.WriteLine("Beep sound through Console with frequence 1000 hertz and duration 500 milliseconds");
      Console.Beep(1000, 500);
   }
}

输出

这将产生以下输出 -

Displaying standard output stream...
Standard Output Stream = System.IO.TextWriter+SyncTextWriter
Beep sound through Console
Beep sound through Console with frequence 1000 hertz and duration 500 milliseconds

更新于: 2019 年 12 月 11 日

171 次浏览

开启你的 职业生涯

完成课程可获得认证

开始
广告