-3

Sorry about this dumb question, but i´ve recently found out that you can declare a String or string variable at C#. I would like to know the difference between them, which one is used at specific situations, etc. Thanks for the help and for your time.

Agmp
  • 3
  • 6

1 Answers1

2

There is no difference String is the Class name and string is the alias.

The generaly rule of thumb that I have followed is that if you declare a variable use the alias.

string foo = "bar";

If you call a method, use the class name

String.IsNullOrEmpty("");

It is exactly the same for the following"

  • Boolean and bool
  • Int32 and int
  • Double and double

etc

David Pilkington
  • 13,043
  • 3
  • 36
  • 65