如何从单独的班级打开/运行班级?

时间:2015-07-21 20:47:10

标签: c# class

我在Xamarin Studio上用C#制作一个简单的DOS操作系统。问题是我已经制作了几个程序来完成我在Visual Studio中对Xamarin所做的事情。

尽我能解释我的困难:我有一个名为OSBootup.cs的类,我希望这个类运行,然后它在我的项目中启动一个不同的类。有没有办法做到这一点?如果没有,我能做的另一种方式是什么?

我的代码:(OSBootup.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 ()
        {

        }
    }
}

1 个答案:

答案 0 :(得分:2)

您有DOSConsole DConsole = new DOSConsole ();,但您遗失了DConsole.Start();.

(答案是:mbeckish)