im writing a multicasting programming. my code is like
UdpClient udpclient = new UdpClient(40975);
IPAddress multicastaddress=IPAddress.Parse("233.1.2.4");
udpclient.JoinMulticastGroup(multicastaddress);
IPEndPoint remote=null;
Encoding enc = Encoding.Unicode;
//while(true)
//{
Byte[] data =udpclient.Receive(ref remote);
String strData = enc.GetString(data);
//Console.WriteLine(data);
textBox1.Text="";
for(int i=0;i
//MessageBox.Show(data[i].ToString());
textBox1.Text=textBox1.Text + data[i].ToString();
}
Now the problem is that I want to convert first 2 byte to integer. But how....
AlanPosted Aug 24, 2007, 4:30 AM
If the first two bytes contain the binary representation of a 'short' integer, then you can get the value with this line:
short value = BitConverter.ToInt16(data, 0);