私が持っているこのプログラムは、任意の座標で文字列を出力します。いくつかの前景色と背景色が含まれている必要があります。警告 1 というエラーが表示されます。フィールド 'ConsoleApplication1.ConsoleText.color' は使用されません。コードは次のとおりです。
class ColoredText
{
public int x = 10;
public int y = 20; // Coordinates
public string Text = "Hello!";
ConsoleColor color = ConsoleColor.Blue;
public ColoredText(int x, int y, string Text)
{
Console.ForegroundColor = color;
Console.BackgroundColor = color;
Console.SetCursorPosition(20, 0);
Console.Clear();
Console.ResetColor();
}
public virtual void Draw()
{
if (x >= 80 || y >= 49 || x < 0 || y < 0)
{
Console.WriteLine("Värdet är inte giltigt");
}
else
{
Console.SetCursorPosition(x, y);
Console.ForegroundColor = ConsoleColor.Blue;
Console.Write(Text);
Console.BackgroundColor = ConsoleColor.Red;
Console.Clear();
}
}
}
エラーの何が問題なのかについてのアイデアはありますか?