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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top