Programming Course in C# ¡Free!

sbyte variable | Store value in data type sbyte

 Saturday, June 13, 2015 published by Exercises C#
sbyte

The sbyte keyword denotes an integral type that stores values from -128 to 127. The size of the data type sbyte is 8 bits.

You can declare and initialize a sbyte variable like this example:

sbyte a = -128;


Proposed Exercise: The first sbyte variable

Create a program in C# to declare a variable of type sbyte. Initializes the variable to 127 and shows the value of the variable display.

using System;

class FirstSbyteVariable
{
    static void Main()
    {
        sbyte a;
        a = 127;

        Console.Write(a);
    }
}


Proposed Exercise: Temperature

Develop a program in C# to request the user temperature and store in a variable of type sbyte.

using System;

class Temperature
{
    static void Main()
    {
        sbyte temperature;
        temperature = sbyte.Parse( Console.ReadLine() );
    }
}