- Data Structure
- Networking
- RDBMS
- Operating System
- Java
- MS Excel
- iOS
- HTML
- CSS
- Android
- Python
- C Programming
- C++
- C#
- MongoDB
- MySQL
- Javascript
- PHP
- Physics
- Chemistry
- Biology
- Mathematics
- English
- Economics
- Psychology
- Social Studies
- Fashion Studies
- Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
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