Error CS5001_Program does not contain a static 'Main' method suitable for an entry point

  • Thread starter Thread starter Maineac
  • Start date Start date
M

Maineac

Guest
Using Visual Studio 2017 I created a new empty solution. I added a Console App project to the solution which created a class named Program with a static void Main(string[] args) function. I added an additional class named "CData" with only one constructor which takes an integer and calculates a time to process based on the integer.

I added code to the Main function to use the command line argument(s) and display the processing time. Here is the Program class:


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace DataSource
{
class Program
{
static int Main(string[] args)
{
int retVal = 0;

if (args.Count<string>().Equals(0))
{
Console.WriteLine("usage: DataSource <Any Integer>");
}
else
{
try
{
int val = 0;
val = Convert.ToInt32(args[0]);

CData dat = new CData(val);
double res = dat.RequestTime.TotalSeconds;

Console.WriteLine($"Processing time: {res} seconds.");

}
catch (Exception ex)
{
retVal = ex.GetHashCode();
Console.WriteLine(ex.Message);
}
}
Console.ReadLine();
return (retVal);
}
}
}

How does this not work?



Scaling the Cliffs of Insanity

Continue reading...
 
Back
Top