Posted on: 5/22/2011 7:42:50 PM | Views : 229

Hi,
Newbie question here :)
I have a method which return a class.
First it looks in session...
If it's not in session it tries to create a new one...
If it can't create it, it returns an new myClass("", "", "") etc;
So, in theory, it will always return something.
 
The question I have is this.
I could write this:
MyClass myclass
{
    get { return myClassHelper(); }  // tries to get it from session first...etc
}
...and access it like this int test = myClass.prop1;
or I could write it like this...
MyClass myClass;
myClass = myClassHelper();
if(myClass != null)
{
    int test = myClass.Prop1;
}
 
I'd like opinions.  Is 2 overkill?  Is 1 insufficient? Pro's, Con's etc.
 
Thanks in advance.
John
 
  ...

Go to the complete details ...