Decode Bool from string - CSharp System

CSharp examples for System:String Encode Decode

Description

Decode Bool from string

Demo Code


using System.Text;
using System.Linq;
using System.Collections.Generic;
using System;/*from  w w  w.  j av  a 2  s  . c  o  m*/

public class Main{
        public static bool DecodeBool(string v)
        {
            try
            {
                int i = Convert.ToInt32(Convert.ToChar(v.Substring(0, 1)));
                return (i == 1);
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
                return false;
            }
        }
}

Related Tutorials