String C # vs String, bool vs Boolean

Are there any differences between line and line / bool and Boolean? Shoud Do I prefer to use one over the other? Or should I just try to avoid the conversion between these types (I already noticed that the application can handle this conversion, but there may be some kind of problem) ... or is it just a pointless question?

+4
source share
5 answers

These are the same things - string is just an alias for System.String and bool for System.Boolean

+10
source

They are exactly the same. But I think it's worth noting (in case you have a multilingual belief) that in Java, Boolean and Boolean types are not the same.

+4
source

bool is an alias for System.Boolean, just as int is an alias for System.Int32. See the complete list of aliases here . and example

 int x = 123; System.Int32 x = 123; 
+3
source

If you look at the documentation, for example for bool , you will see that these are just aliases, so any conversions are not needed.

I rarely saw that System.String and System.Boolean are used explicitly, aliases are used much more often (in some projects, in 100% of cases, even to call static methods such as string.Join(...) )

+2
source

No differences - just another syntactic sugar, since one is a set of keywords, and the other is a set of types. They compile to the same thing. Most stores / people choose the format they prefer and stick with it ... I use lowercase keywords instead of type.

+1
source

Source: https://habr.com/ru/post/1486687/


All Articles