C # Learning Diary---Boolean type of data type

Source: Internet
Author: User
Boolean type of value type:

Boolean types are used to denote the two concepts of ' true ' and ' false ', although they may seem simple, but they are very widely used. We know that computers use binary to represent a variety of data, with only 0 or 1 inside it. The Boolean type represents a logical variable of only 2, True or False.

In this case, we contrast the C + +, the meaning of Boolean type C/C + +, which means "true" or "false" values, 0 means ' false ' other than 0 of the number means ' true ' this irregular expression is discarded in C #. True, False in C # cannot be substituted with other values, there is no conversion between an integer type and a Boolean type, which means that converting an integer type to a Boolean type is illegal.

BOOL X=1//Error

BOOL X=true or x = false//correct

Next, define a Boolean variable and output:

Using System;  Using System.Collections.Generic;  Using System.Linq;  Using System.Text;    Namespace Example  {      class program      {          static void Main (string[] args)          {              bool b=true;            Console.WriteLine (b);}}  

The result is:

     True

The above is the C # Learning Diary---Data type of the Boolean type of content, more relevant content please pay attention to topic.alibabacloud.com (www.php.cn)!

  • Related Article

    Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.