Xamarin Studio 中的第一个 Hello World 应用程序出现问题

Trouble with first Hello World app in Xamarin Studio

所以我开始学习如何编程并拿起一本 c# 书并在我的 Mac 上下载了 Xamarin Studio 以开始使用。我正在使用的书不可避免地使用 Visual Studio 但我认为它本质上是相同的,但我已经遇到了一些问题:

  1. 当我第一次创建一个新的控制台应用程序时,它会自动启动一个 hello world 模板。有没有什么方法可以让 IDE 在没有这条线的情况下开始,因为我确信它会在路上变得有点烦人:

    Console.WriteLine("Hello World!");

换句话说,我可以修改 Xamarin Studio 启动的模板吗?

  1. 当我用下面的程序点击 运行 ---> Start Debugging 时,我得到相同的结果就像我 运行 程序没有调试的时候。在这两种情况下,应用程序都按预期完全运行,但在我的书中,作者提到屏幕应该闪烁一瞬间,除非你包括 Console.ReadKey(); 我有什么想念的吗?当我包含那条额外的行时,无论我 运行 是否进行调试,我都会得到必须按两次键才能结束程序的预期结果。

这里是确切的源代码:

using System;
namespace test
{
    class MainClass
    {
        public static void Main(string[] args)
        {
            Console.WriteLine("Hello World!");
        }
    }
}

When I first create a new console application, it automatically starts up with a hello world template. Is there any way to make the IDE start without this line, as I'm sure it can become somewhat of an annoyance down the road

这个想法很有趣,但由于模板本身表明其黑色控制台应用程序,它应该有一些成功运行的代码。

When I click on Run ---> Start Debugging with the program below, I get the same result as when I run the program without debugging. In both cases, the application fully works as expected, but in my book the author mentions the screen should flash for a split second, unless you include Console.ReadKey(); Is there anything I am missing? And when I include that extra line, I get the expected result of having to push a key twice to end the program regardless of whether I run with or without debugging.

嗯,这就是 Xamarin Studio 的工作原理。您的问题的答案在于如何配置 Xamarin Studio。默认情况下,Xamarin studio 会处理一些事情,有一个默认暂停控制台的选项。如果您想查看 Console.ReadKey() 的实际效果,只需右键单击您的项目并转到选项 -> 运行 -> 常规 -> 取消选中(暂停控制台输出)。

但由于 Xamarin Studio 中没有内置控制台,因此使用外部控制台(默认为终端),您将无法看到闪光效果。

希望这对您有所帮助。谢谢,编码愉快 :)