C# - Downside to Setting Initial Value in Declaration
Posted
by tyndall
on Stack Overflow
See other posts from Stack Overflow
or by tyndall
Published on 2010-06-08T14:36:07Z
Indexed on
2010/06/08
14:42 UTC
Read the original article
Hit count: 122
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?
© Stack Overflow or respective owner