如何从一个单独的类打开/运行一个类
本文关键字:一个 运行 单独 | 更新日期: 2023-09-27 18:03:48
我在Xamarin Studio上用c#制作一个简单的DOS操作系统。问题是,我在Visual Studio中编写了几个程序来做我在Xamarin上做不到的事情。
尽我所能解释我的困难:我有一个名为OSBootup.cs
的类,我想让这个类运行,然后它在我的项目中启动了一个不同的类。有什么办法吗?如果不行,还有什么别的方法吗?
我的代码:(osboot .cs)
using System;
using System.IO;
using System.Threading;
namespace OperatingSystemCore
{
public static class OSBootup
{
public static void Main (String[] args)
{
bool isStarting;
Start:
isStarting = true;
Console.Write ("Starting SyteraOS ");
Thread.Sleep (1000);
Console.Write (". ");
Thread.Sleep (1000);
Console.Write (". ");
Thread.Sleep (1000);
Console.Write (". ");
Thread.Sleep (1000);
Console.Clear ();
Console.Write ("Starting SyteraOS ");
Thread.Sleep (1000);
Console.Write (". ");
Thread.Sleep (1000);
Console.Write (". ");
Thread.Sleep (1000);
Console.Write (". ");
Thread.Sleep (4500);
Console.Clear ();
Console.WriteLine ("Press Any Key To Start SyteraOS ...");
Console.ReadKey ();
End:
DOSConsole DConsole = new DOSConsole ();
isStarting = false;
}
}
}
如果你需要看我的另一个文件,(DOSConsole.cs):
using System;
namespace OperatingSystemCore
{
public class DOSConsole
{
public void Start ()
{
Console.WriteLine ("Give us a name.");
Console.WriteLine ("");
Console.Write ("Name: ");
string Name = Console.ReadLine ();
Console.Clear ();
Console.Write ("User->" + Name);
}
public void Update ()
{
}
public void Commands ()
{
}
}
}
您有DOSConsole DConsole = new DOSConsole ();
,但您缺少DConsole.Start();.
(回答是:mbeckish)