If you write the code, it says that the entry point does not contain the main method.

Asked 2 years ago, Updated 2 years ago, 42 views

Start the following code

Severity level code description project file line suppression state
Error The CS5001 program does not contain the appropriate static 'Main' method at the entry point. Project 26 C:\Users\aozaki hinagi\Documents\Visual Studio 2017\Projects\Project 26\Project 26\CSC1 Active

appears.

using System;
using System.Collections.General;
using System.Linq;
using System.Text;
using System.Net;

namespace Chap5
{
    class DnsGetHostAddresses
    {
        public static void Main (string[]args)
        {
            // Get Hostname
            string hostName=Dns.GetHostName();

            // Obtain IP Address List
            IPAddress [ ] addresses = Dns.GetHostAddresses (hostName);
            foreach (IPAddress address in addresses)
            {
                Console.WriteLine("Address notation:" + address.ToString());

                // Output the byte array of IP addresses across
                Console.WriteLine(
                    "Byte column: {0}\n", string.Join(", ", address.GetAddressBytes()));
            }

            Console.ReadKey();
        }
    }
}

However, I don't understand the error if I don't include the main.
Could someone tell me?

Thank you for your cooperation.

c#

2022-09-30 19:38

1 Answers

In my experience, when I have the above questions, the build action is often changed by some impetus.
Please check the following.


2022-09-30 19:38

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.