本文介绍了C#中的bool和Boolean有什么区别?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

C#中的bool和Boolean有什么区别?
.
我们可以将new与Boolean一起使用吗?

bool B = true;
Console.WRILTElINE(布尔值IS {0}:",B);
因此显示为< b> True</b>.为什么?

What is the difference between bool and Boolean in c#?
.
can we use new with Boolean?

bool B=true;
Console.WRILTElINE("tHE BOOL VALUE IS{0}:",B);
so it is display <b>True</b> why?

推荐答案


using System;
using System.Collections.Generic;
using System.Text;

namespace ConsoleApplication2
{
    class Program
    {
        static void Main(string[] args)
        {
            bool b = true;

            int a = 10;
            if (a < 1)
            {
                Console.WriteLine("value of b is :"+b);
            }
            else
            {
                b = false;
                Console.WriteLine("value of b is :" + b);
            }
        }
    }
}



只需尝试更改整数变量"a"的值,您就会发现窍门...
现在进入您的问题的第一部分,即bool和Boolean之间的区别

我的朋友bool是System.Boolean jsut的别名,例如int是System.Int32的别名,也就是它:)

一旦发现有用,请对我的回答进行评分

谢谢&问候
基数:rose:



just try changing value for integer variable "a" and u will see the trick...
Now coming to the first part of your question thats difference between bool and Boolean

my friend bool is an alias for System.Boolean jsut like int is an alias for System.Int32 thats it :)

please do rate my answer once u find it useful

Thanks & Regards
Radix :rose:



这篇关于C#中的bool和Boolean有什么区别?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-02 01:12