IPHostEntry 的问题 内有源码
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.IO;
using System.Net;
using System.Text.RegularExpressions;
namespace WindowsApplication1
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
public void button1_Click(object sender, EventArgs e)
{
string ip = this.textBox1.Text;
IPHostEntry hostinfo = Dns.GetHostByName(textBox1.Text);
//textBox1.Text = Convert.ToString(hostinfo);
bool blnTest = false;
bool _Result = true;
Regex regex = new Regex( "^[0-9]{1,3}.[0-9]{1,3}.[0-9]{1,3}.[0-9]{1,3}$ ");
blnTest = regex.IsMatch(textBox1.Text);
if (blnTest == true)
{
string[] strTemp = this.textBox1.Text.Split(new char[] { '. ' }); // textBox1.Text.Split(new char[] { '. ' });
for (int i = 0; i < strTemp.Length; i++)
{
if (Convert.ToInt32(strTemp[i]) > 255)
{ //大于25