- value
- The decimal value to be converted.
true if value is non-zero; false if value is zero.
Documentation for this section has not yet been entered.
The following example demonstrates converting decimal values to bool values.
C# Example
using System; class ConvertBoolTest { static public void Main() { decimal decimal0 = 0m; decimal decimal1 = 1m; decimal decimal2 = -2m; bool bool0 = Convert.ToBoolean(decimal0); bool bool1 = Convert.ToBoolean(decimal1); bool bool2 = Convert.ToBoolean(decimal2); Console.WriteLine("(decimal) {0} as bool = {1}",decimal0,bool0); Console.WriteLine("(decimal) {0} as bool = {1}",decimal1,bool1); Console.WriteLine("(decimal) {0} as bool = {1}",decimal2,bool2); } }The output is
(decimal) 0 as bool = False
(decimal) 1 as bool = True
(decimal) -2 as bool = True
Namespace: System
Assembly: mscorlib (in mscorlib.dll)
Assembly Versions: 1.0.5000.0, 2.0.0.0