المساعد الشخصي الرقمي

مشاهدة النسخة كاملة : How to use bytes in bytes buffer?



C# Programming
07-24-2009, 02:12 PM
Hello,
i was trying to simplify my code but i have a problem with the code here:
public void Send(byte a, byte b, byte c)
{
byte[] ab = new byte[3];
ab[0] = a;
ab[1] = b;
ab[2] = c;
ab[3] = a ^ b ^ c;
serialPort1.Open();
serialPort1.Write(ab, 0, 3);
serialPort1.Close();
}

When is use this code there is an error in this line:
ab[3] = a ^ b ^ c;
the error is:
Error 1 Cannot implicitly convert type 'int' to 'byte'. An explicit conversion exists (are you missing a cast?) C:\Users\***\AppData\Local\Temporary Projects\WindowsFormsApplication1\Form1.cs 27 21 WindowsFormsApplication1

Is there some one that can help me?