NetWork
{
    class NetWork
    {
        
public static void Main(string[] args)
        {
//          
            string[]   slist     =   {"12.123.23.4","12.23.*.56","23.34.*.*","12.23.3*.1"};
             Regex   rg   
=   new   Regex(@"^(\d{1,3}|\*)\.(\d{1,3}|\*)\.(\d{1,3}|\*)\.(\d{1,3}|\*)$");   
//           foreach   (string   s   in   slist)   
//           Console.WriteLine("{0}:{1}",   s,   rg.IsMatch(s));   

            Console.WriteLine(
"Input HostName!");
            
string pHostName=Console.ReadLine ();
            IPHostEntry myAddress
=Dns.GetHostByName(pHostName);
            Console.WriteLine (
"{0} IP Address is ",pHostName);
            IPAddress[] myIpAddress
=myAddress.AddressList;
            
foreach(IPAddress ip in myIpAddress)
            {
                Console.WriteLine (ip);
            }
            
string pAddress=Console.ReadLine ();
            
do
            {
            
             
if(rg.IsMatch (pAddress))
             {
               IPHostEntry myHostName
=Dns.GetHostByAddress(pAddress);
               Console.WriteLine (
"{0}对应的主机名{1}:",pAddress,myHostName.HostName.ToString ());
             }
            
else
            {
                Console.WriteLine (
"IP 格式不对");
            }
             pAddress
=Console.ReadLine ();
            }
while(!pAddress.Equals("0"));
            
        }
    }
}

相关文章:

  • 2022-12-23
  • 2021-05-17
  • 2021-09-05
  • 2021-10-27
  • 2021-06-02
  • 2022-01-24
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2021-12-09
  • 2021-04-09
  • 2021-08-14
  • 2022-01-12
  • 2021-08-30
  • 2022-12-23
相关资源
相似解决方案