- value
- The 8-bit signed integer value to be converted.
true if value is non-zero; false if value is zero.
This member is not CLS-compliant. For a CLS-compliant alternative, use Convert.ToBoolean(object)(short).
The following example demonstrates converting sbyte values to bool values.
C# Example
using System; class ConvertBoolTest { static public void Main() { sbyte sbyte0 = (sbyte) 0; sbyte sbyte1 = (sbyte) 1; sbyte sbyte2 = (sbyte) -2; bool bool0 = Convert.ToBoolean(sbyte0); bool bool1 = Convert.ToBoolean(sbyte1); bool bool2 = Convert.ToBoolean(sbyte2); Console.WriteLine("(sbyte) {0} as bool = {1}",sbyte0,bool0); Console.WriteLine("(sbyte) {0} as bool = {1}",sbyte1,bool1); Console.WriteLine("(sbyte) {0} as bool = {1}",sbyte2,bool2); } }The output is
(sbyte) 0 as bool = False
(sbyte) 1 as bool = True
(sbyte) -2 as bool = True
Namespace: System
Assembly: mscorlib (in mscorlib.dll)
Assembly Versions: 1.0.5000.0, 2.0.0.0