In .NET, what is the difference between String.Empty
and \"\"
, and are they interchangable, or is there some underlying reference or Localization i
Coming at this from an Entity Framework point of view: EF versions 6.1.3 appears to treat String.Empty and "" differently when validating.
string.Empty is treated as a null value for validation purposes and will throw a validation error if it's used on a Required (attributed) field; where as "" will pass validation and not throw the error.
This problem may be resolved in EF 7+. Reference: - https://github.com/aspnet/EntityFramework/issues/2610 ).
Edit: [Required(AllowEmptyStrings = true)] will resolve this issue, allowing string.Empty to validate.