How can I fetch the form inside a file created in solution explorer in c#?

G_M 6 Reputation points
2022-05-26T08:23:49.883+00:00

When calling a form in solution explorer I use:

Form1 go= new Form1();
go.ShowDialog();

But what code should I write to fetch the form in the file?

Exp:

Form2 go2= new NewFolder.Form2();
go2.ShowDialog();

C#
C#
An object-oriented and type-safe programming language that has its roots in the C family of languages and includes support for component-oriented programming.
10,234 questions
{count} vote

1 answer

Sort by: Most helpful
  1. Karen Payne MVP 35,036 Reputation points
    2022-05-26T10:04:29.017+00:00

    When a form resides in a folder within the project it's namespace will be different so you need to reference in this case Form2 to it's namespace.

    Example, say the project name is WinFormDemo and Form2 is in a folder named WinFormDemo\Forms.

    Form2 go2 = new WinFormDemo.Forms.Form2();

    1 person found this answer helpful.