What is the difference between this initialization metods?

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 6:41 UTC
Read the original article Hit count: 414

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 metod is preferd?

© Stack Overflow or respective owner

Related posts about c#

Related posts about .NET