bool and Boolean

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I am using VS2005 Beta2

In the VS.NET IDE, the Intellisense drop-down shows both bool and Boolean.
What is the difference between the two? Similarly, it shows string and String
('s' capitalized). What is the difference between string and String?
 
In the VS.NET IDE, the Intellisense drop-down shows both bool and Boolean.
What is the difference between the two?

bool is a C# keyword, Boolean is not. But they represent the same type, bool
is just a shortcut for System.Boolean. The difference is that bool, being a
keyword, works in all contexts. To use Boolean you have to import the System
namespace or fully qualify it as System.Boolean.

You have the same thing with string/String, float/Single, int/Int32 and
other primitive types.


Mattias
 
Just to add...the reason why it is like this is for language portability. A
C# bool is equal to a VB Boolean or a System.Boolean. It won't make a
difference, just use what you're comfortable with.

Cheers,
Mark
 
Back
Top