在C#中获取IP地址的步骤如下:
using System.Net;
string hostName = Dns.GetHostName();
IPHostEntry hostEntry = Dns.GetHostEntry(hostName);
IPAddress[] ipAddressList = hostEntry.AddressList;
foreach (IPAddress ipAddress in ipAddressList)
{
Console.WriteLine(ipAddress.ToString());
}
通过以上步骤,就能够在C#中获取本地主机的IP地址。