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#:为什么是“布尔"而不是“布尔"


基础教程推荐
- MS Visual Studio .NET 的替代品 2022-01-01
- 如何激活MC67中的红灯 2022-01-01
- 将 XML 转换为通用列表 2022-01-01
- 有没有办法忽略 2GB 文件上传的 maxRequestLength 限制? 2022-01-01
- rabbitmq 的 REST API 2022-01-01
- SSE 浮点算术是否可重现? 2022-01-01
- 如何在 IDE 中获取 Xamarin Studio C# 输出? 2022-01-01
- 为什么Flurl.Http DownloadFileAsync/Http客户端GetAsync需要 2022-09-30
- 将 Office 安装到 Windows 容器 (servercore:ltsc2019) 失败,错误代码为 17002 2022-01-01
- c# Math.Sqrt 实现 2022-01-01