I wanted to avoid running the code HttpContext.Current.Server.MapPath
every time file_path_includes
is called.
Is the below an effective way of doing so?
private static string file_path_includes_;
public static string file_path_includes
{
get
{
if (file_path_includes_ == null)
file_path_includes_ = HttpContext.Current.Server.MapPath("/_includes") + @"\";
return file_path_includes_;
}
}
So the better implentation would be a static constructor as such:
public static string file_path_includes;
static ParentClassName()
{
file_path_includes = HttpContext.Current.Server.MapPath("/_includes") + @"\";
}