Checks if the given input equals one of the values. - CSharp System

CSharp examples for System:String Parse

Description

Checks if the given input equals one of the values.

Demo Code

//     TelerikAcademy.com. All rights reserved.
using System.Text.RegularExpressions;
using System.Text;
using System.Security.Cryptography;
using System.Linq;
using System.Globalization;
using System.Collections.Generic;
using System;//ww w. j  a  va2  s  . c o  m

public class Main{
        /// <summary>
        /// Checks if the given input equals one of the values.
        /// </summary>
        /// <param name="input">Input line.</param>
        /// <returns>Returns boolean which checks if the input line contains any of the given values.</returns>
        public static bool ToBoolean(this string input)
        {
            var stringTrueValues = new[] { "true", "ok", "yes", "1", "??" };
            return stringTrueValues.Contains(input.ToLower());
        }
}

Related Tutorials