Transform the meaning of boolean value in integer value - CSharp System

CSharp examples for System:Boolean

Description

Transform the meaning of boolean value in integer value

Demo Code


using System.Web;
using System.Web.UI.WebControls;
using System.Collections;
using System.Text;
using System;//w ww . ja v  a2  s .c  o  m

public class Main{
        /// <summary>
        /// Transform the meaning of boolean value in integer value
        /// </summary>
        /// <param name="value">true/false value to be transformed</param>
        /// <returns>1 if the value is true, 0 if the value is false</returns>
        private static int boolToNum(bool value)
        {
            return value ? 1 : 0;
        }
}

Related Tutorials