cosmos (C#) で OS を作成していますが、コードを正しく取得できません。ここにあります:
var input = Console.ReadLine();
if (input = 'h')
Console.Write("This is the help section...");
else
Console.Write("Invalid Command.");
Console.WriteLine(input);
私がやりたいのは、「H」と入力するとヘルプセクションが出力され、他の何かを入力すると「無効なコマンド」と入力されることです。
「エラー: タイプ 'char' を 'string' に暗黙的に変換できません。
完全なコード
using System;
using System.Collections.Generic;
using System.Text;
using Sys = Cosmos.System;
namespace Dingo_OS
{
public class Kernel : Sys.Kernel
{
protected override void BeforeRun()
{
Console.WriteLine("Thank you for trying out my OS. For any help, input /h.");
}
protected override void Run()
{
var input = Console.ReadLine();
if (input = 'h')
Console.Write("This is the help section...");
else
Console.Write("Invalid Command.");
Console.WriteLine(input);
}
}
}