简体   繁体   中英

C# Setting Form 2 as Startup

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"

According to your comments, your form Form2 lives within the Uploader namespace. If that is the entire namespace then:

At the top of Program.cs , add in:

 using Uploader;

or

If you are using Visual Studio, it has a handy feature that allows you to right-click on where the error occurs (the Application.Run line), and it will give you the option to automagically add in the using for you.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM