C#: why #39;bool#39; instead of #39;boolean#39;(C#:为什么是“布尔而不是“布尔)
问题描述
可能重复:
布尔类型和布尔类型有什么区别C#
为什么 C# 使用单词 bool
而不是 boolean
来表示布尔类型?
Why does C# use the word bool
intead of boolean
for boolean types?
(我只是浪费了 5 分钟试图找出我的代码无法编译的原因!)
(I just wasted 5 mins trying to work out why my code wasn't compiling!)
推荐答案
大概是因为这是 C++ 用于其布尔类型的关键字,而 C# 保留了大部分语法以帮助熟悉该语言的程序员更轻松地迁移.旧习惯难改.
Presumably because that's the keyword C++ uses for its boolean type, and C# retains much of the syntax to help programmers comfortable with that language migrate more easily. Old habits die hard.
它也更短,可以节省打字时间.程序员是出了名的懒惰,这是有充分理由的.
It's also shorter, which saves typing. Programmers are a notoriously lazy bunch, and for good reason.
但请记住,bool
只是 C# 中 aliassystem.boolean.aspx" rel="noreferrer">System.Boolean
类型.如果您愿意,当然可以使用 Boolean
代替(当然,您必须将其大写,因为 C# 区分大小写).
But remember that bool
is only an alias in C# for the System.Boolean
type. You can certainly use Boolean
instead if you prefer (but of course, you'll have to capitalize it, since C# is case-sensitive).
这篇关于C#:为什么是“布尔"而不是“布尔"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:C#:为什么是“布尔"而不是“布尔"


- C#MongoDB使用Builders查找派生对象 2022-09-04
- Web Api 中的 Swagger .netcore 3.1,使用 swagger UI 设置日期时间格式 2022-01-01
- 如何用自己压缩一个 IEnumerable 2022-01-01
- 在哪里可以找到使用中的C#/XML文档注释的好例子? 2022-01-01
- 带有服务/守护程序应用程序的 Microsoft Graph CSharp SDK 和 OneDrive for Business - 配额方面返回 null 2022-01-01
- C# 中多线程网络服务器的模式 2022-01-01
- MoreLinq maxBy vs LINQ max + where 2022-01-01
- 良好实践:如何重用 .csproj 和 .sln 文件来为 CI 创建 2022-01-01
- WebMatrix WebSecurity PasswordSalt 2022-01-01
- 输入按键事件处理程序 2022-01-01