我在ConsoleKeyInfo遇到了一个非常愚蠢的问题.我想检查是否使用小键盘或常规顶部数字键输入"1".
ConsoleKeyInfo keyPressed;
keyPressed = Console.ReadKey();
if (keyPressed = ConsoleKey.D1 || keyPressed = ConsoleKey.NumPad1)
{ }
Run Code Online (Sandbox Code Playgroud)
由于某种原因,我不能使用"||" 运营商.如果循环没有使用Console.ReadLine();并强制用户按Enter键,是否有可能在1以内检查它?
我写了一些类列表,这是我用来初始化类的代码
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)