Get IP address in a console application
问题 I am looking to figure out what my IP address is from a console application. I am used to a web application by using the Request.ServerVariables collection and/or Request.UserHostAddress . How can this be done in a console app? 回答1: The easiest way to do this is as follows: using System; using System.Net; namespace ConsoleTest { class Program { static void Main() { String strHostName = string.Empty; // Getting Ip address of local machine... // First get the host name of local machine.