1

in c#, i want to set forum 2 as startup form from program.cs, but when i try to change the code piece below i get such an error

before changing:

static void Main()
        {

            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            Application.Run(new Form1());
        }

after changing:

static void Main()
    {

        Application.EnableVisualStyles();
        Application.SetCompatibleTextRenderingDefault(false);
        Application.Run(new Form2());
    }

the error is : The type or namespace name 'Form2' could not be found (are you missing a using directive or an assembly reference?)

All my changes are to write "Form2" instead of "Form1"

4

1 回答 1

3

根据您的评论,您的表单Form2位于Uploader命名空间内。如果这是整个命名空间,那么:

在 顶部Program.cs,添加:

 using Uploader;

或者

如果您使用的是 Visual Studio,它有一个方便的功能,允许您右键单击发生错误的位置(Application.Run行),它会为您提供自动添加的选项using

于 2013-06-26T09:48:32.447 回答