gpt4 book ai didi

c# - 找不到类型或命名空间窗口

转载 作者:行者123 更新时间:2023-12-04 16:54:01 25 4
gpt4 key购买 nike

我很困惑为什么窗口不会出现在下面的代码中。我错过了导入吗?

using System.Text;
using System.Xml;
using System.Windows;
using System;
using System.Windows.Forms;
using System.IO;
using System.Threading;

public class Program {

public Window mainWindow;

static void main() {

// Create the application's main window
mainWindow = new Window();
mainWindow.Title = "Enter SN";
mainWindow.Show();
}
}

最佳答案

您想通过 Application.Run() 运行您的窗口称呼。您当前的代码不会在标准 Windows 消息循环上触发它,这是必需的。

删除您的 Show() 调用并将其替换为:

Application.Run(mainWindow);

更简单地说,如果您在 WinForms 设计器中将标题设置为您的愿望,则 main 可以是一行:
Application.Run(new Window());

此外,您有许多不必要的 using 语句。这些陈述不是真正的问题,只是不必要且令人困惑。

关于c# - 找不到类型或命名空间窗口,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7999786/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com