📄 ipendpointsample.cs
字号:
//IPEndPointSample.cs
using System;
using System.Net;
class IPEndPointSample
{
public static void Main()
{
IPAddress newaddress = IPAddress.Parse("192.168.1.1");
//创建IPEndPoint实例
IPEndPoint ex = new IPEndPoint(newaddress, 8000);
Console.WriteLine("The IPEndPoint is:{0}", ex.ToString());
Console.WriteLine("The AddressFamily is:{0}", ex.AddressFamily);
Console.WriteLine("The Address is:{0},and the port is:{1}", ex.Address, ex.Port);
Console.WriteLine("The Min Port Number is:{0}", IPEndPoint.MinPort);
Console.WriteLine("The Max Port Number is:{0}", IPEndPoint.MaxPort);
//用port属性单独改变IPEndPoint对象的端口值
ex.Port = 80;
Console.WriteLine("The changed IPEndPoint vaule is:{0}", ex.ToString());
//存储IPEdnPoint实例
SocketAddress sa = ex.Serialize();
Console.WriteLine("The Socketaddress is:{0}", sa.ToString());
Console.ReadLine();
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -