Convert a System.String into a System.Boolean using System.Convert : System Convert « Data Type « C# / CSharp Tutorial






using System;

using System.Globalization;

class MainClass
{
  static void Main(string[] args)
  {      
    string theString = "true";
    Console.WriteLine("Convert.ToBoolean(theString)");        
    bool theBool = Convert.ToBoolean(theString);
    Console.WriteLine("Type code string converted to bool is: {0}", theBool.GetTypeCode());
    Console.WriteLine("Value of converted string: {0}", theBool);
  }
}
Convert.ToBoolean(theString)
Type code string converted to bool is: Boolean
Value of converted string: True








2.56.System Convert
2.56.1.Use System.Convert to convert string to Int16
2.56.2.Convert a System.String into a System.Boolean using System.Convert
2.56.3.Convert.ChangeType
2.56.4.data type convert