What is the difference between bool and Boolean types in C#

Viewed 212357

What is the difference between bool and Boolean types in C#?

15 Answers

I don't believe there is one.

bool is just an alias for System.Boolean

They are one in the same. bool is just an alias for Boolean.

They are the same. Boolean helps simplify conversion back and forth between C# and VB.Net. Most C# programmers tend to prefer 'bool', but if you are in a shop where there's a lot of both VB.Net and C# then you may prefer Boolean because it works in both places.

As has been said, they are the same. There are two because bool is a C# keyword and Boolean a .Net class.

bool is an alias for the Boolean class. I use the alias when declaring a variable and the class name when calling a method on the class.

No actual difference unless you get the type string. There when you use reflection or GetType() you get {Name = "Boolean" FullName = "System.Boolean"} for both.

Related