Home > Back-end >  How to fix C# error cs1556 "'Program' specified for Main method must be a non-generic
How to fix C# error cs1556 "'Program' specified for Main method must be a non-generic

Time:02-15

I'm trying to learn C# currently, and my first attempt at a program is this:

using System;
namespace Program {
    class Circle {
        double radius;
        double diameter;
        double circumference;
        double area;

        public void SetVals() {
            radius = 9;
            diameter = 2*radius;
            circumference = 2*Math.PI*radius;
            area = Math.Pow((Math.PI*radius),2);
        }

        public void Disp() {
            Console.WriteLine("Radius = {0}", radius);
            Console.WriteLine("Diameter = {0}", diameter);
            Console.WriteLine("Circumference = {0}", circumference);
            Console.WriteLine("Area = {0}", area);
        }
    }

    class ExecCircle {
        static void Main(string[] args) {
            Circle c = new Circle();
            c.SetVals();
            c.Disp();
            Console.ReadKey();
        }
    }
}

But when I run it, I get the error cs1556 "'Program' specified for Main method must be a non-generic class, record, struct, or interface". Does anyone know what I did wrong and how to fix it? I'd appreciate the help as I can't seem to figure it out.

CodePudding user response:

Make sure the project is set up correctly, it runs fine on my system and on an online compiler.

  • Related