Bool.parse method in C#

CsharpProgrammingServer Side Programming

To convert a string to a bool, use the Bool.parse method in C# −

Firstly, set a string −

string str = "true";

Now, convert it to bool −

bool.Parse(str);

Here is the complete code −

Example

 Live Demo

using System;
using System.Linq;
class Demo {
   static void Main() {
      string str = "true";
      bool res = bool.Parse(str);
      Console.WriteLine(res);
   }
}

Output

True
raja
Published on 05-Sep-2018 14:09:22
Advertisements