byte

In this chapter you will learn:

  1. Define and use byte type
  2. Min/Max value of byte
  3. byte hexadecimal literal

byte type

using System; //j  a v a2s.c o  m
 
public class Use_byte {    
  public static void Main() {    
    byte x; 
    int sum; 
 
    sum = 0; 
    for(x = 1; x <= 100; x++) 
      sum = sum + x; 
 
    Console.WriteLine("Summation of 100 is " + sum); 
  }    
}

Min/Max value of byte

The data type defines the max and min values which it can hold.

using System;/* j  av a2s . co  m*/

class Program
{
    static void Main(string[] args)
    {
        Console.WriteLine(byte.MaxValue);
        Console.WriteLine(byte.MinValue);

    }
}

The output:

byte hexadecimal literal

using System;//j  a va 2  s.  c  o  m

public class Example
{
   public static void Main()
   {
      byte b = 0x00;
      b = 0x12;
      b = 0x34;
      b = 0x56;

   }
}

Next chapter...

What you will learn in the next chapter:

  1. Convert int to byte
  2. Convert double to byte
  3. Using Convert.ToByte to convert value to byte
Home » C# Tutorial » Byte, Integer, Long
Integer Family
Integer ranges
byte
Convert to byte
Parse string to byte
byte format
byte octal and hexadecimal
byte binary operation
byte overflow with unchecked
int
int value
Compare int value
int calculation
int value overflow
int binary operation
Parse string to int value
Format int value
int in binary, octal and hexadecimal
long
long value calculation
ulong