9
Is there any downside to a class like:
class Example1
{
protected string UserId = (string)Session["user"];
}
//versus
class Example2
{
protected string UserId;
public Example2()
{
UserId = (string)Session["user"];
}
}
If I always want to set this value is there any downside to Example1?
UPDATE:
Session["user"] is set in the Global.asax Session_Start. So if this fails. Nothing should work anyways.