C# Program to convert a Byte value to an Int32 value

CsharpProgrammingServer Side Programming

To convert a Byte value to an Int32 value, use the Convert.ToInt32() method.

Int32 represents a 32-bit signed integer.

Let’s say the following is our Byte value.

byte val = Byte.MaxValue;;

Now to convert it to Int32.

int intVal = Convert.ToInt32(val);

Let us see the complete example.

Example

 Live Demo

using System;
public class Demo {
   public static void Main() {
      byte val = Byte.MaxValue;;
      int intVal = Convert.ToInt32(val);
      Console.WriteLine("Converted byte {0} to Int32 {1} value ", val, intVal);
   }
}

Output

Converted byte 255 to Int32 255 value
raja
Published on 14-Sep-2018 12:50:45
Advertisements