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#:为什么是“布尔"而不是“布尔"
基础教程推荐
- 将事件 TextChanged 分配给表单中的所有文本框 2022-01-01
- 错误“此流不支持搜索操作"在 C# 中 2022-01-01
- 在 VS2010 中的 Post Build 事件中将 bin 文件复制到物 2022-01-01
- 如何动态获取文本框中datagridview列的总和 2022-01-01
- 首先创建代码,多对多,关联表中的附加字段 2022-01-01
- 是否可以在 asp classic 和 asp.net 之间共享会话状态 2022-01-01
- 经典 Asp 中的 ResolveUrl/Url.Content 等效项 2022-01-01
- 全局 ASAX - 获取服务器名称 2022-01-01
- 从 VS 2017 .NET Core 项目的发布目录中排除文件 2022-01-01
- JSON.NET 中基于属性的类型解析 2022-01-01
