我确信以前有人问过这个问题,但在这个例子中,我很好奇其他人在将常数分离到这种程度时能看到什么用处:
public class CoreStringConstants
{
// Common strings
public const string SPACE = " ";
public const string PERIOD = ".";
public const string COMMA = ",";
public const string COLON = ":";
public const string SEMI_COLON = ";";
public const string HYPHEN = "-";
public const string UNDER_SCORE = "_";
public const string LEFT_BRACKET = "(";
public const string RIGHT_BRACKET = ")";
public const string LEFT_SQUARE_BRACKET = "[";
public const string RIGHT_SQUARE_BRACKET = "]";
public const string LEFT_CURLY_BRACKET = "{";
public const string RIGHT_CURLY_BRACKET = "}";
public const string PIPE = "|";
public const string CIRCUMFLEX = "^";
public const string ASTERISK = "*";
... 真的?
将这些类型的字符串常量从您的代码中分离出来真的有什么好处吗?
在可预见的应用程序生命周期内,用于 ASTERISK 的字符何时会发生变化?