Wrox Programmer Forums
Go Back   Wrox Programmer Forums > C# and C > C# 1.0 > C#
|
C# Programming questions specific to the Microsoft C# language. See also the forum Beginning Visual C# to discuss that specific Wrox book and code.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the C# section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old September 24th, 2007, 08:25 AM
Authorized User
 
Join Date: Dec 2005
Posts: 28
Thanks: 0
Thanked 0 Times in 0 Posts
Default Casting - Can you help

        // SELECT CARRD METHOD FIX1
        public void SELECTcard()
{

         byte[] buff = new byte[5];
         buff[0] = 4; //áðî¼ íà bytes âî buff
         buff[1] = 186;
         //BAh
         buff[2] = 2;
         //len(bytes)
         buff[3] = 1;
         //01h
         buff[4] = buff[1] ^ buff[2] ^ buff[3]; // the error is here //please can you help
         //checksum
         sndCARD(buff);

}
//Error 1 Cannot implicitly convert type 'int' to 'byte'. An explicit conversion exists (are you missing a cast?)


 
Old September 24th, 2007, 08:41 AM
Authorized User
 
Join Date: Nov 2006
Posts: 93
Thanks: 0
Thanked 1 Time in 1 Post
Default

Your error gives you your answer ...

buff[4] = (byte)(buff[1]^buff[2]^buff[3]);

What you don't know can hurt you!





Similar Threads
Thread Thread Starter Forum Replies Last Post
Casting pfrigo BOOK: Professional .NET 2.0 Generics 3 November 19th, 2007 04:49 PM
Casting Problem liorlankri ASP.NET 1.x and 2.0 Application Design 2 January 2nd, 2007 03:31 AM
casting ravibodani Access 1 April 4th, 2006 01:19 PM
Casting question shantawn J2EE 4 August 2nd, 2005 02:40 AM
Dynamic Casting pareshsoft C# 2 December 1st, 2004 12:12 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.