AGENT.Contrib.Util.Parse.TryParseBool C# (CSharp) Метод

TryParseBool() публичный статический Метод

Attempt to parse the provided string value.
public static TryParseBool ( string s, bool &val ) : bool
s string String value to be parsed
val bool Variable to set successfully parsed value to
Результат bool
        public static bool TryParseBool(string s, out bool val)
        {
            val = false;
            try
            {
                if (s == "1" || s.ToUpper() == bool.TrueString.ToUpper())
                {
                    val = true;

                    return true;
                }
                else if (s == "0" || s.ToUpper() == bool.FalseString.ToUpper())
                {
                    val = false;

                    return true;
                }

                return false;

            }
            catch
            {
                return false;
            }
        }