\"ERROR\" Program does not contain a static \'Main\' method suitable for an entr
ID: 3772396 • Letter: #
Question
"ERROR" Program does not contain a static 'Main' method suitable for an entry point
Here is my code, I am not sure what I am missing, I am running is visual studio 2015
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Globalization;
namespace Test
{
public static class StringHelper
{
private static CultureInfo ci = new CultureInfo("en-US");
//Convert all first latter
public static string ToTitleCase(this string str)
{
str = str.ToLower();
var strArray = str.Split(' ');
if (strArray.Length > 1)
{
strArray[0] = ci.TextInfo.ToTitleCase(strArray[0]);
return string.Join(" ", strArray);
}
return ci.TextInfo.ToTitleCase(str);
}
public static string ToTitleCase(this string str, TitleCase tcase)
{
str = str.ToLower();
switch (tcase)
{
case TitleCase.First:
var strArray = str.Split(' ');
if (strArray.Length > 1)
{
strArray[0] = ci.TextInfo.ToTitleCase(strArray[0]);
return string.Join(" ", strArray);
}
break;
case TitleCase.All:
return ci.TextInfo.ToTitleCase(str);
default:
break;
}
return ci.TextInfo.ToTitleCase(str);
}
}
public enum TitleCase
{
First,
All
}
}
Explanation / Answer
the following are thr fixes for the above program:
1)Check the properties of App.xaml. The Build Action should be Application Defination.
2)Project Properties Output file -> Select Class Library :)
3)ALL VB/C#programs need to contain the Main() method. Essentially this is where the program starts. The code you posted is just a small part of the entire application. You must have removed the location where main had been residing.
A new Windows Form App has a Program class that instantiates the form that you want.
Try copying that over to a new file called program.cs. Make sure that Form1 now points to the form you created in the applications.
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.