C# Convert ToDecimal(Boolean)
Description
Convert ToDecimal(Boolean)
converts the specified
Boolean value to the equivalent decimal number.
Syntax
Convert.ToDecimal(Boolean)
has the following syntax.
public static decimal ToDecimal(
bool value
)
Parameters
Convert.ToDecimal(Boolean)
has the following parameters.
value
- The Boolean value to convert.
Returns
Convert.ToDecimal(Boolean)
method returns The number 1 if value is true; otherwise, 0.
Example
The following example illustrates the conversion of Boolean to Decimal values.
//from www . java 2 s. c o m
using System;
public class MainClass{
public static void Main(String[] argv){
bool[] flags = { true, false };
decimal result;
foreach (bool flag in flags)
{
result = Convert.ToDecimal(flag);
Console.WriteLine("Converted {0} to {1}.", flag, result);
}
}
}
The code above generates the following result.