ipandname.cs
来自「Csharp实例编程百例.rar」· CS 代码 · 共 22 行
CS
22 行
using System;
using System.Net;
class IpAndName
{
static void Main(string[] args)
{
DnsPermission DnsP=new DnsPermission(System.Security.Permissions.PermissionState.Unrestricted);
DnsP.IsUnrestricted();
string ComputerName=Dns.GetHostName();
IPHostEntry myHost=new IPHostEntry();
myHost=Dns.Resolve(ComputerName);
//myHost=Dns.GetHostByName(ComputerName);
Console.WriteLine("The name of this computer is : {0}",ComputerName);
Console.WriteLine("The IP of this computer is:");
for(int i=0;i<myHost.AddressList.Length;i++)
{
Console.WriteLine("{0}",myHost.AddressList[i].ToString());
}
}
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?