17

are there any diferences between string and String/bool and Boolean? Shoud I prefer using one over other one? Or should I just try to avoid converting between these types (I already noticed that application is able to deal with this convert, but there could be some problem)...or is it just pointless question?

Eleer
  • 528
  • 3
  • 5
  • 20
  • See [this](http://stackoverflow.com/q/134746/1037210) and [this](http://stackoverflow.com/q/7074/1037210) – Lion Jun 17 '13 at 19:40
  • What's the difference between a duck? – Matthew Jun 17 '13 at 19:41
  • I think, that people, who answer these questions on SO, must receive -1000 votes automatically. – Dennis Jun 17 '13 at 19:42
  • 1
    @Dennis not really. Its acceptable to be not rude to someone new to SO, and an answer is welcome. But I sincerely hope OP removes this question. We already have a lot of this. – nawfal Jun 17 '13 at 19:48

5 Answers5

13

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

4

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

Bathsheba
  • 220,365
  • 33
  • 331
  • 451
3

bool is an alias for System.Boolean just as int is an alias for System.Int32. See a full list of aliases Here. and Example

int x = 123;
System.Int32 x = 123;
Nik
  • 86
  • 4
2

If you look at the documentation, for example for bool, you'll see that they are just aliases, so any conversions are unnecessary.

I've rarely seen System.String and System.Boolean used explicitly, the aliases are used much more often (in some projects in 100% of cases, even for calling static methods like string.Join(...))

Honza Brestan
  • 9,621
  • 2
  • 32
  • 42
1

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

Haney
  • 28,087
  • 7
  • 52
  • 64