C#: why 'bool' instead of 'boolean' [duplicate]
Possible Duplicate:
What is the difference between Bool and Boolean types in C#
Why does C# use the word bool
intead of boolean
for boolean types?
(I just wasted 5 mins trying to work out why my code wasn't compiling!)
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.
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).
Same reason it uses int for integer. programmers are lazy. :)
It is just the decision the language designer made, probably because it is shorter. It is also the keyword many languages use.
Perhaps the same reason they chose int
instead Integer
or Int32
- a similarity with C++!
Probably because if historical reasons. bool and BOOL types were often used in C and C++ libraries that preceded C#.
Because the inventor of the Boolean logic was named Bool*e* (thanks Cody). So you got Bools and boolean operators to operate on them. Makes sense, not?
bool is simply an alias of System.Boolean
- meant to save you 3 characters per declaration :)
Pretty much all C style languages use "bool", it's not something that's peculiar to C# by any means...
精彩评论