Possible Duplicates:
String vs string in C#
C#: why 'bool' instead of 'boolean'
Should I use 'bool' (keyword) or 'Boolean' (aliased type)? Similarly 'char' or 'Char'? Why is aliased type created? What's its usefulness? Thanks.
Possible Duplicates:
String vs string in C#
C#: why 'bool' instead of 'boolean'
Should I use 'bool' (keyword) or 'Boolean' (aliased type)? Similarly 'char' or 'Char'? Why is aliased type created? What's its usefulness? Thanks.
If you are in C# it is preferebale to use 'bool', since it is native for language. 'Boolean' is a common .NET runtime type, so there would not be any issues of using cause it is the same thing.
Anyway, it is recomened to stick to Language syntax/notation, instead on CRL syntax/notation.
It's shorter. When your code is compiled, Boolean and Char will be in the IL. Up to you if you want to use, I'd just follow the same standard throughout the code.
The System.Boolean
/System.Char
type is the real thing. The keyword is just a convenience to access this type.
I mostly use the keyword. The exception are integer types when I want to emphasize the bit size of the type. Then I use a type like UInt16
instead of ushort
.
bool
and char
(which are the aliases, not keywords) are less to type, and they match their pendants in a lot of other broadly used programming languages. So prefer those (like 99,9% of the C# programmers folk do.)
One difference is that Boolean
may not always be System.Boolean
(imagine a Boolean
class in the current namespace or an explicit import Boolean = ...
); it just normally is because of import System;
. On the other hand, bool
is always System.Boolean
and there is no ambiguity about what is meant.
I always use the "short aliases" (where one exists) -- the aliases are part of the language, why not use them?
Happy coding.