Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

C# isn't detecting my static Main() for an entry point

Visual Studio 2019 is acting like this static void Main() doesn’t exist.

using System;

namespace Paint
{

    class Program
    {
        void static Main(string[] args)
        {
            Paint();
        }
        void Paint()
        {
            string[] tiles = new string[256];
            var newkey = Console.Read();
            int paint = Convert.ToInt32(newkey);
            tiles[paint] = "Test";
            Console.WriteLine(tiles[paint]);
            Console.Beep();
            Console.ReadKey();
            Paint();
        }
    }
}

I tried to put the Main() at the front of the function, but that didn’t work.

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

your problem is

#1.add static before Methods

#2.change Name Method

#3.comment // Paint();

if you want recursive or repeat Method that you must review and change your code

this is correct code


using System;

namespace Paint;


class Program
{
    static void Main(string[] args)
    {
        Paintn();
    }
    static void Paintn()
    {
        string[] tiles = new string[256];
        var newkey = Console.Read();
        int paint = Convert.ToInt32(newkey);
        tiles[paint] = "Test";
        Console.WriteLine(tiles[paint]);
        Console.Beep();
        Console.ReadKey();
       // Paint();
    }
}
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading