Program of addition of byte type variables – c# program, DOT NET Programming

Program of addition of byte type variables - C# Program

Program of addition of byte type variables, i need program code for performing addition of byte type variables. Can anybody send me there ideas?

Posted Date: 2/11/2013 5:56:31 AM | Location : United States





Yes, i have an example regarding your problem you specified above. Try this it is beneficial for you.

Program - addition of byte type variables

using System; 

class addition 

          public static void Main() 

               { 

                  byte b1; 

                  byte b2; 

                  int b3; // We are required to declare b3 as byte BUT its declared as int. The reason is given below. 

                  b1 = 100; 

                  b2 = 200; 

             // Normally this is the addition statement  

            //        b3 = b1 + b2; 

           // However it gives an error that cannot convert ''int'' to ''byte''. 

           // When b2 & b3 are added, we get an integer value which cannot be stored in byte b1 

           // Thus we will declare b3 as integer type & explicitly convert b2 & b3 to int. 

                 b3 = (int)b1 + (int)b2; 

                 Console.WriteLine("b1 = " + b1);  

                 Console.WriteLine("b2 = " + b2); 

                 Console.WriteLine("b3 = " + b3); 

                 Console.ReadLine(); 

              } 

}

Posted by Alice | Posted Date: 2/11/2013 5:58:40 AM

Thank you, for your expert advice. You have described very useful code.

Posted by Jermy | Posted Date: 2/11/2013 6:02:12 AM


Related Discussions:- Program of addition of byte type variables – c# program, Assignment Help, Ask Question on Program of addition of byte type variables – c# program, Get Answer, Expert's Help, Program of addition of byte type variables – c# program Discussions

Write discussion on Program of addition of byte type variables – c# program
Your posts are moderated
Related Questions
HOW TO DESIEN THE CALENDER IN ASP . NET

Simple FB Integration in MS-SQL and ASP.NET I am seeking urgent project to be done, please I am interested in someone who will present demo for retrieving personal informatio

What is DCOM? DCOM is different from COM in that it allows for creating objects distributed around  a network, and a protocol for invoking that object's methods, & secures the

Image Generator (Ngen.exe) The Ngen.exe (Native Image Generator) allows you to run the JIT compiler on your assembly's MSIL and generate native machine code which is cached to

What are the main components of .NET Framework? .NET Framework gives enormous benefits to software developers in comparison to the advantages given by other platforms. Microsof

What is .NET Framework? .NET Framework is a complete environment that permits developers to develop, run, and deploy the following applications:     Windows services

Printing Triangles - C# Program I need program code for Printing Triangles in C#. Can anybody send me there ideas?

What is a DataReader object? The DataReader object helps in retrieving the data from a database in a forward-only, read-only mode. The base class for all the DataReader objects

Which command-line tool generates code and mapping for the LINQ to SQL component of .NET Framework? The SqlMetal.exe command-line tool generates code and map the LINQ to SQL co

Describe all elements in Static Chart diagrams. Package: - The Package logically groups element of a UML model. Class: - The Class describes all set of objects with