Can abyone tell me what type of variable is a standard Form1?

It's just a curiosity and not a real part of a project.

here is the standard code visual studio starts with in my version 2010 when creating a new forms application with a couple of lines added/amended..

namespace AdoptChrome
{
    static class Program
    {

        /// <summary>
        /// The main entry point for the application.
        /// </summary>
        [STAThread]
        static void Main()
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            var instance = new Form1(); //<============== This here
            Application.Run(instance);
            instance.cleanup();// this cleans up some external library mess.

        }

    }
}

I expect that Form1 is a class, but I cannot use that as a type because of some error or other.
So I simply use "var", however that is what my question is.

What actual real type could I use instead of var?

My app is working as expected up to now, but I cannot find the correct term to a get a good answer from a web search.

Thanks for reading.

Recommended Answers

All 2 Replies

What actual real type could I use instead of var?

The type is Form1, since that's the name of the class, and it derives from System.Windows.Forms.Form:

Form1 instance = new Form1();

I'd have sworn I tried that, must have tried Form instead.

Thanks deceptikon.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.