Convert.ToBoolean (String) converts string to Boolean equivalent. : Convert to Boolean « Development « VB.Net






Convert.ToBoolean (String) converts string to Boolean equivalent.

  

Module BooleanConversion
   Public Sub Main()
      ConvertToBoolean(String.Empty)
      ConvertToBoolean("true")
      ConvertToBoolean("TrueString")
      ConvertToBoolean("False")
      ConvertToBoolean("    false    ")
      ConvertToBoolean("-1")
      ConvertToBoolean("0")
   End Sub

   Private Sub ConvertToBoolean(value As String)
      Try
         Console.WriteLine("Converted '{0}' to {1}.", value,Convert.ToBoolean(value))
      Catch e As FormatException
         Console.WriteLine("Unable to convert '{0}' to a Boolean.", value)
      End Try
   End Sub
End Module

   
    
  








Related examples in the same category

1.Convert.ToBoolean converts 8-bit unsigned integer to Boolean value.
2.Convert.ToBoolean(Decimal) converts decimal number to Boolean value.
3.Convert.ToBoolean(Double) converts double number to Boolean value.
4.Convert.ToBoolean(Int16) converts 16-bit signed integer to Boolean value.
5.Convert.ToBoolean (Int32) converts 32-bit signed integer to Boolean value.
6.Convert.ToBoolean (Int64) converts 64-bit signed integer to Boolean value.
7.Convert.ToBoolean (Object) converts object to Boolean value.
8.Convert.ToBoolean (SByte) converts 8-bit signed integer to Boolean value.
9.Convert.ToBoolean (Single) converts single-precision number to Boolean value.
10.Convert.ToBoolean (UInt16) converts 16-bit unsigned integer to Boolean value.
11.Convert.ToBoolean (UInt32) converts 32-bit unsigned integer to Boolean value.
12.Convert.ToBoolean (UInt64) converts 64-bit unsigned integer to Boolean value.