ここでの私の考えは、テキストベースのアドベンチャーゲームを作成することです。
メインクラスでクラスを使用しようとしています。私がしようとしている間、それは私にエラーを与えます:
「MyAdventure.Window」は「タイプ」ですが、「変数」のように使用されます
これを解決する方法がわかりません。クラスの新しいインスタンスを作成しようとしましたが、機能しなかったようです。私はこれにかなり慣れていませんが、誰か助けてもらえますか?
前もって感謝します。
これが私のメインクラス(Program.cs)のコードです:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace MyAdventure
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine("You cannot feel your body. You don't know where you are.\nThe room you're in is dark. You cannot see much.");
Console.WriteLine("You decide to stand up, and take a look around. You see a door and a window.\nWhich do you check out first?");
Console.WriteLine("A. Window\nB. Door");
string userInput = Console.ReadLine();
//Window theWindow = new Window();
if (userInput.StartsWith("A", StringComparison.CurrentCultureIgnoreCase))
{
Window();
}
else if (userInput.StartsWith("B", StringComparison.CurrentCultureIgnoreCase))
{
Console.WriteLine("You chose the door.");
}
Console.ReadKey();
}
}
}
そして、これは他のクラスWindow.csの(これまでの)コードです:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace MyAdventure
{
public class Window
{
static void theWindow()
{
Console.WriteLine("You approach the window.");
Console.ReadKey();
}
}
}