C#中的bool和Boolean有什么区别? [英] What is the difference between bool and Boolean in c#?

查看:155
本文介绍了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?

推荐答案

bool是System.Boolean的别名,就像int是System.Int32的别名一样.请参见此处 [此处 [ ^ ].
bool is an alias for System.Boolean just as int is an alias for System.Int32. See here[^]. To check a full list of aliases see here[^].


你好,
布尔值是一种数据类型,将仅返回两个值true或false,因为您声明了一个名为B的布尔值并初始化了一个值为true的值,并且如果您要尝试显示b,则您显示的代码将最终返回true值布尔值的一些示例,然后我的朋友为您提供正确的代码

Hello,
Boolean is a datatype that will return u only two values either true or false the code which you have displayed will defiantely return a true value because u have declared a Boolean value named B and initialized a value true to it and displayed b if u wana try some examples with boolean then my friend heres the right code for you

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:


没有任何区别.
您可以使用bool或Boolean来获得完全相同的结果.
There is NO difference whatsoever.
You may use either bool or Boolean with exactly the same results.


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

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆