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#:为什么是“布尔"而不是“布尔"
基础教程推荐
- 如果有人提交恶意软件Nuget包怎么办? 2022-01-01
- WPF 模态进度窗口 2022-01-01
- 如何使用 .Net 检查 Active Directory 服务器是否已启动并正在运行? 2022-01-01
- Azure Functions:CosmosDBTrigger 未在 Visual Studio 中触发 2022-01-01
- 我应该在后面的代码中直接使用 Linq To SQL 还是使 2022-01-01
- C# 从 List<List<int>> 中删除重 2022-01-01
- Moq It.Is<>不匹配 2022-01-01
- .NET SerialPort DataReceived 事件未触发 2022-01-01
- 当值可以是对象或空数组时反序列化 JSON 2022-01-01
- 禁止输入少量字符,例如'<'、'&a 2022-01-01
