Hi,
I am use following code to find IP address of machine in C#.write following code in class file.
when build the solution it gives following error
1.The best overloaded method match for 'string.String(char*)' has some invalid arguments
2.Argument '1':cannot convert from 'string' to 'char*'
How to solve this error and access this class file in form

public static int MainIP(string [] args)
        {
            String strHostName = new String("");

            if (args.Length == 0)
            {
              
                strHostName = Dns.GetHostName();
                Console.WriteLine("Local Machine Name :" + strHostName);
            }
            else
            {
                strHostName = args[0];
            }

            IPHostEntry ipEntry = Dns.GetHostEntry(strHostName);
            IPAddress[] addr = ipEntry.AddressList;

            for (int i = 0; i < addr.Length; i++)
            {
                Console.WriteLine("IP Address {0}: {1} ", i, addr[i].ToString());
            }
            return 0;
        }

Edited 7 Years Ago by ShailaMohite: n/a

The code for find IP address and machine name in Windows Programming

private void button1_Click(object sender, EventArgs e)
        {
            
            string myHost = System.Net.Dns.GetHostName();

            System.Net.IPHostEntry myIPs = System.Net.Dns.GetHostEntry(myHost);

            // Loop through all IP addresses and display each 

            foreach (System.Net.IPAddress myIP in myIPs.AddressList)
            {

                MessageBox.Show(myIP.ToString());

            }
        }

Edited 7 Years Ago by ShailaMohite: n/a

This question has already been answered. Start a new discussion instead.