C# Convert ToInt16(Boolean)

Description

Convert ToInt16(Boolean) converts the specified Boolean value to the equivalent 16-bit signed integer.

Syntax

Convert.ToInt16(Boolean) has the following syntax.


public static short ToInt16(
  bool value
)

Parameters

Convert.ToInt16(Boolean) has the following parameters.

  • value - The Boolean value to convert.

Returns

Convert.ToInt16(Boolean) method returns The number 1 if value is true; otherwise, 0.

Example


/*  ww w.  jav a  2s.  c o  m*/
using System;
public class MainClass{
  public static void Main(String[] argv){  
    Console.WriteLine(Convert.ToInt16(true));
  }
}
    

The code above generates the following result.





















Home »
  C# Tutorial »
    System »




Array
BitConverter
Boolean
Byte
Char
Console
ConsoleKeyInfo
Convert
DateTime
DateTimeOffset
Decimal
Double
Enum
Environment
Exception
Guid
Int16
Int32
Int64
Math
OperatingSystem
Random
SByte
Single
String
StringComparer
TimeSpan
TimeZone
TimeZoneInfo
Tuple
Tuple
Tuple
Type
UInt16
UInt32
UInt64
Uri
Version