Convert String To Bool - CSharp System

CSharp examples for System:Converter

Description

Convert String To Bool

Demo Code


using System.Threading.Tasks;
using System.Text;
using System.Linq;
using System.Collections.Generic;
using System;//from w w w. ja  v a 2  s  . c  o  m

public class Main{
        public static bool ConvertStringToBool(string value)
        {
            bool boolValue;
            if (!bool.TryParse(value, out boolValue))
            {
                throw new Exception("String is not in the right format - Bool");
            }
            return boolValue;
        }
}

Related Tutorials