For example, suppose I have an error message, "Error: ", that I might want to change to "There was a problem: ". Instead of search and replace n times, I could just use a static string variable to change the string value.
Sample Global class:
Then one just accesses it with Global.ERROR_HEADER. Notice that there is no declarative instantiation for the static class.
/// <summary>
/// Summary description for Global
/// </summary>
public static class Global
{
public static string CSS_HIDDEN
{
get { return "hidden"; }
}
public static string CSS_EMPTY
{
get { return string.Empty; }
}
public static string CSS_CONTENT
{
get { return "content1"; }
}
public static string ERROR_HEADER_HTML
{
get { return "<red>There was a problem:</red></br>"; }
}
public static string ERROR_HEADER
{
get { return "There was a problem:"; }
}
}
Reference: http://dotnetperls.com/Content/Global-Variables-ASPNET.aspx
No comments:
Post a Comment