Click here to Skip to main content
15,896,063 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I get a build error.
CS0246 Type or Namespace name 'FrmNewmonth' could not be found.
I have added the form and its code to the project, which shows up under references.

I am not sure where or how to declare FrmNewMonth.cs

I am pretty new to C# so I ask some basic qusitions.

What I have tried:

C#
//this.Hide();
//this.Hide();
FrmNewMonth pantryForm = new FrmNewMonth();
pantryForm.Show();
//Application.EnableVisualStyles();
//Application.SetCompatibleTextRenderingDefault(false);
//Application.Run(new frmFoodPantry());


And I get a build error.
CS0246 Type or Namespace name 'FrmNewmonth' could not be found.
I have added the form and its code to the project, which shows up under references.

And I get a build error.
CS0246 Type or Namespace name 'FrmNewmonth' could not be found.
I have added the form and its code to the project, which shows up under references.
Posted
Updated 5-Jul-22 7:40am
v2
Comments
Richard MacCutchan 5-Jul-22 14:40pm    
Look at the error message: your class is named FrmNewMonth with a capital 'M' for month, not FrmNewmonth. So find the line with the incorrect spelling.

1 solution

It's telling you you don't have a class (a Form is a class!) called "FrmNewMonth" defined anywhere.

Oh, and C# is case-sensitive. "frmNewMonth" is not the same as "FrmNewMonth".
 
Share this answer
 
v2
Comments
PaulaJoannAllen 5-Jul-22 14:02pm    
Yeah, I found out it was case-sensitive the hard way.

How do I declare it as a class when I have already brought the code into the main project?

I know this is a newbie question, and I should know it.
Dave Kreskowiak 5-Jul-22 14:19pm    
I have no idea what you're talking about with the code.

To rename a form, you click on the form itself in the designer (NOT a control on it!) and in the Properties window, there's a (Name) property. Change that and it changes the name of the form. You have to use that name in your code when referring to that class.

The designer writes the code for the form (class) itself.
PaulaJoannAllen 5-Jul-22 14:47pm    
That worked; I did a copy-paste from the form name and had to add a using statement. So it works now.
Richard MacCutchan 5-Jul-22 15:52pm    
If it is part of the same project and namespace, you should not need a using statement.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900