socket 发送和接收 编码问题。 发送和接收都使用UTF8就肯定可以了 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 我用的是VS2012 UTF8不行。。 接收端:UdpClient client = new UdpClient(7901); IPEndPoint ep = null; byte[] data = client.Receive(ref ep); string data_receive = Encoding.UTF8.GetString(data); Console.WriteLine(data_receive);发送端: UdpClient client = new UdpClient(); IPEndPoint ep = new IPEndPoint(IPAddress.Parse("127.0.0.1"), 7901); byte[] bytes = Encoding.UTF8.GetBytes("成功!!!,.;"); client.Send(bytes, bytes.Length, ep);效果: UTF8是国际标准,基本上所有的字符集都可以。你的接收代码呢? C#在textbox中输入数据,然后插入到datagridview中 c#如何为foreach语句中的空值赋值? 急急如律令 SQL版块没人 帮顶有分 请问如何分批 密发 邮件?(用System.Net.Mail) 大伙们帮忙解决哈? 一个字段 求救:如何清除掉一个处于死循环的线程,在线等。 使用C#通过ODBC方式采集SQL Server数据的方式,求指教 C/S模式,数据传输 用C#可以调用API吗? gridview指定一行变色 C#如何实现把图像缩小10倍后再放大10倍而图像质量不变(即不发虚)
我用的是VS2012 UTF8不行。。
UdpClient client = new UdpClient(7901);
IPEndPoint ep = null;
byte[] data = client.Receive(ref ep);
string data_receive = Encoding.UTF8.GetString(data);
Console.WriteLine(data_receive);
发送端:
UdpClient client = new UdpClient();
IPEndPoint ep = new IPEndPoint(IPAddress.Parse("127.0.0.1"), 7901);
byte[] bytes = Encoding.UTF8.GetBytes("成功!!!,.;");
client.Send(bytes, bytes.Length, ep);
效果: