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.
Asked
Active
Viewed 3,431 times
-3
-
string is like an alias for String. – kelsier Nov 29 '13 at 05:49
-
You could've considered googling for such a question and would've got about a million answers. Also, learning basics in .Net would help. – Shakti Prakash Singh Nov 29 '13 at 07:50
1 Answers
3
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,528
- 3
- 41
- 73