This signed byte type represents a small integer that can be negative or positive. It is 8 bits or 1 byte and it stores integers between -128 and 127. It is less commonly used.
using System;
sbyte val = 1;
// Local variable.
Console.WriteLine(
"val: {0}", val);
Console.WriteLine(
"sizeof: {0}", sizeof(sbyte));
Console.WriteLine(
"default: {0}", default(sbyte));
Console.WriteLine(
"min: {0}", sbyte.MinValue);
Console.WriteLine(
"max: {0}", sbyte.MaxValue);
Console.WriteLine(
"type: {0}", val.GetType());
Console.WriteLine(
"code: {0}", val.GetTypeCode());
if (val == 1)
// Test.
{
Console.WriteLine(
"1: {0}", true);
}
val++;
// Increment.
Console.WriteLine(
"val: {0}", val);
val: 1
sizeof: 1
default: 0
min: -128
max: 127
type: System.SByte
code: SByte
1: True
val: 2