Here's a tutorial to get your IP Address using C#.
N.B: Beginners please follow the link to know How to create your First Windows Form Application.
1. Open Visual Studio -> New Project -> Windows Forms Application. Give name as
IP Address and press OK. (See the Screenshot)
2. Now design your Form as shown in the below image. (Change the Form
backcolor and Form text from the Properties window to make your form same as
the one shown below)
3. Now click on the Form and get the event handler for Form Load and update the code
with the one shown below.
public partial class Form1 : Form
private void Form1_Load(object sender, EventArgs e)
string localIP = string.Empty;
host = Dns.GetHostEntry(Dns.GetHostName());
foreach (IPAddress ip in host.AddressList)
if (ip.AddressFamily.ToString() == "InterNetwork")
localIP = ip.ToString();
textBox1.Text = localIP;
4. Run your Application and get your form with your IP Address. In case of any errors /
doubts, please feel free to comment; I am happy to help you.