0

Possible Duplicate:
What is the difference between String.Empty and “”

Which one is better?

name = System.String.Empty; 

OR

name = "";
Community
  • 1
  • 1
Leany
  • 159
  • 1
  • 2
  • 5

3 Answers3

0

I do it because FxCop complains if I don't. More readable?, hardly.

Ash Machine
  • 9,601
  • 11
  • 45
  • 52
0

I use "" as it's considerably easier on the eye than String.Empty. It hasn't caused me any problems as of yet, and I've been developing in .Net for years.

Will A
  • 24,780
  • 5
  • 50
  • 61
-1

Edit: This is only true till .NET 1.1. as per What is the difference between String.Empty and "" (empty string)? not true for later versions.

If you say "" you are creating a new object, where as String.Empty is a read-only field already initialized, it creates no object.

Community
  • 1
  • 1
YetAnotherUser
  • 9,156
  • 3
  • 39
  • 53