Is there a named constant like string.Space to replace " "
c#
Solution
There is none, but you can define your own.
public static class MyString
{
public const string Space = " ";
}
Then use it like:
Console.Write("Test" + MyString.Space + "Text");
EDIT But you shouldn't, IMO (and based on comments from Marc Gravell and PaulRuane) since that will make the code less readable
Problem
Using `string.Empty` instead of `""` is really cute and make the code more clear. I'm wondering if there's a good named constant to replace `" "` too. I've found some ideas like using `string.Empty.PadLeft(1)` or `string.Empty.PadRight(1)`, but I don't like it. Something like `string.Space` to use instead of `" "` would be appropriate for the situation. (Edited after comments) To make my question's situation more clear: In the multicultural situations, there shouldn't be any code like `"Can not open the file"`. The string literals should be moved to a resource file and then use like `Resources.CanNotOpenTheFile`. To make sure that happens, It seems a good rule, not to have any string literals in the code. So looking code at a glance, you can find bad implementations quickly. I think that's a good explanation of why I'm trying not to use `"` in the code.