Help with my c# code and advise for a beginner c# coder

so basically

CSC : error CS1555: Could not find 'Program' specified for Main method [/home/runner/small-test-field/main.csproj]

the above is the error given when im running the code, can anyone help out, here the code

using System;

using System.Threading.Tasks;

public class timespan

{

    public static void Main()

    {

        Task t1 = Task.Run(() =>
        {

            Random r = new Random();

            long sum1 = 0;

            int n = 2000000;

            for (int i = 1; i <= n; i++)
            {

                int number = r.Next(0, 101);

                sum1 += number;

            }

            Console.WriteLine("Total: {0:N0}", sum1);

            Console.WriteLine("Mean: {0:N2}", sum1 / n);

            Console.WriteLine("N: {0:N0}", n);

        });

        TimeSpan ts = TimeSpan.FromMilliseconds(120);

        if (!t1.Wait(ts))

            Console.WriteLine("timeout interval expires");

    }

}

change timespan to Program

1 Like

You’ve renamed the class Program to timespan. If this code is in Main.cs, you need the public class Program. You can then create other separate C# files and use using to import them.

1 Like

Thanks you very much man

You can mark the post that helped you most as a Solution.

2 Likes

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.