Article Categories
- All Categories
-
Data Structure
-
Networking
-
RDBMS
-
Operating System
-
Java
-
MS Excel
-
iOS
-
HTML
-
CSS
-
Android
-
Python
-
C Programming
-
C++
-
C#
-
MongoDB
-
MySQL
-
Javascript
-
PHP
Selected Reading
Boolean.TryParse() Method in C#
The Boolean.TryParse() method in C# is used to convert the specified string representation of a logical value to its Boolean equivalent.
Syntax
Following is the syntax −
public static bool TryParse (string val out bool result);
Example
Let us now see an example to implement the Boolean.TryParse() method −
using System;
public class Demo {
public static void Main(){
bool val;
bool flag;
val = Boolean.TryParse("true", out flag);
Console.WriteLine("Result = "+val);
}
}
Output
This will produce the following output −
Result = True
Example
Let us now see another example to implement the Boolean.TryParse() method −
using System;
public class Demo {
public static void Main(){
bool val;
bool flag;
val = Boolean.TryParse("$", out flag);
Console.WriteLine("Result = "+val);
}
}
Output
This will produce the following output −
Result = False
Advertisements
