What is the difference between this initialization methods?

Posted by Samvel Siradeghyan on Stack Overflow See other posts from Stack Overflow or by Samvel Siradeghyan
Published on 2010-03-19T06:34:28Z Indexed on 2010/03/19 7:01 UTC
Read the original article Hit count: 416

Filed under:
|

Hi all
What is the difference between this two codes?

class SomeClass   
{   

   SomeType val = new SomeType();   

}   

and

class SomeClass  
{      
   SomeType val;   

   SomeClass()   
   {   
       val = new SomeType();   
   }   

}   

Which method is preferd?

© Stack Overflow or respective owner

Related posts about c#

Related posts about .NET