Form1.cs
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Net;
using System.Net.Sockets;
namespace DemoWindowApplication
{
public partial class Form9 : Form
{
public Form9()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
try
{
IPHostEntry hostname = Dns.GetHostByName(textBox1.Text);
IPAddress[] ip = hostname.AddressList;
textBox2.Text =
ip[0].ToString();
}
catch (Exception ex)
{
Console.WriteLine(ex.ToString());
}
}
}
}
0 comments
Post a Comment