Open In App

C# | Boolean.Parse() Method

Last Updated : 11 Jul, 2025
Comments
Improve
Suggest changes
1 Like
Like
Report

This method is used to convert the specified string representation of a logical value to its Boolean equivalent.
 

Syntax:  

public static bool Parse (string value);


Here, the value is the string which contains the value to convert.
Return Value: This method returns true if value is equivalent to TrueString false if value is equivalent to FalseString.
Exceptions:  

  • ArgumentNullException: If the string value is null.
  • FormatException: If the value is not equivalent to TrueString or FalseString.


Below programs illustrate the use of Boolean.Parse(String) Method:
Example 1: 


Output: 
'true' parsed as True
'TRUE' parsed as True
'false' parsed as False
'FALSE' parsed as False
'True' parsed as True
'False' parsed as False

 

Example 2: For ArgumentNullException


Output: 
Exception Thrown: System.ArgumentNullException

 

Example 3: For FormatException


Output: 
Exception Thrown: System.FormatException

 

Note: The value parameter, optionally preceded or trailed by white space, must contain either TrueString or FalseString otherwise, it will throw an exception and the comparison is case-insensitive.
Reference: 


Similar Reads