大佬教程收集整理的这篇文章主要介绍了将接收到的 NetworkStream 字符串转换为对象,大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
我正在尝试从服务器上的客户端接收数据并使用 TcpListener 接收数据我已成功从客户端获取数据。所以我将数据接收为字符串,但我想使用 C# Visual studio 将该数据转换为对象。 Listener.Start();
// Is someone trying to call us? Well answer!
TcpClIEnt ourTCP_ClIEnt = Listener.AcceptTcpClIEnt();
//A network stream object. We'll use this to send and receive our data,so create a buffer for it...
NetworkStream ourStream = ourTCP_ClIEnt.GetStream();
byte[] data = new byte[ourTCP_ClIEnt.ReceiveBufferSize];
// read the incoming data stream - note that Read() is a blocking call...
int bytesRead = ourStream.Read(data,System.Convert.ToInt32(ourTCP_ClIEnt.ReceiveBufferSizE));
// echo the data we got to the console until the newline,and delay closing our window.
//messageBox.Show("Received : " + EnCoding.ASCII.GetString(data,bytesRead));
Console.Writeline("Received : " + EnCoding.ASCII.GetString(data,bytesRead));
authors = Encoding.ASCII.GetString(data,bytesRead);
String[] multiArray = authors.Split(new Char[] { '|' });
String stdID = multiArray[0];
String subjID = multiArraY[1];
String ChangeNo = multiarray[2];
String Ipaddress = multiArraY[3];
String Section = multiArraY[4];
String markAttend = multiarray[5];
String currentDate = multiArraY[6];
String currentTime = multiArraY[7];
studentAttendance stdAtd = new studentAttendance
{
Sid = stdID,subjectId = subjID,CNo = ChangeNo,IP = Ipaddress,section = Section,mark = markAttend,date = currentDate,time = currentTime
};
以上是大佬教程为你收集整理的将接收到的 NetworkStream 字符串转换为对象全部内容,希望文章能够帮你解决将接收到的 NetworkStream 字符串转换为对象所遇到的程序开发问题。
如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。