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;
}