小编Eas*_*asy的帖子

如何检查ConsoleKeyInfo是否按下了2个可能的键中的任何一个?

我在ConsoleKeyInfo遇到了一个非常愚蠢的问题.我想检查是否使用小键盘或常规顶部数字键输入"1".

 ConsoleKeyInfo keyPressed;
 keyPressed = Console.ReadKey();
 if (keyPressed = ConsoleKey.D1 || keyPressed = ConsoleKey.NumPad1)
 { }
Run Code Online (Sandbox Code Playgroud)

由于某种原因,我不能使用"||" 运营商.如果循环没有使用Console.ReadLine();并强制用户按Enter键,是否有可能在1以内检查它?

c# console-application

1
推荐指数
1
解决办法
49
查看次数

使用静态属性打印实例数据

我写了一些类列表,这是我用来初始化类的代码

  public class Album
   {
       static public int IDNumber { get; set; }
       static public string AlbumName { get; set; }
       static public string Artist { get; set; }
       static public int ReleaseDate { get; set; }
       static public int TrackAmount { get; set; }
       static public string Location { get; set; }
       static public int Rating { get; set; }

       public Album(int _id, string _name, string _artist, int _releasedate, int _trackamount, string _location, int _rating)
       {
           IDNumber = _id; …
Run Code Online (Sandbox Code Playgroud)

c#

0
推荐指数
1
解决办法
63
查看次数

标签 统计

c# ×2

console-application ×1