.NET immutable object usage best practices? Should I be using them as much as possible?
        Posted  
        
            by Daniel
        on Stack Overflow
        
        See other posts from Stack Overflow
        
            or by Daniel
        
        
        
        Published on 2010-04-01T00:52:44Z
        Indexed on 
            2010/04/01
            3:53 UTC
        
        
        Read the original article
        Hit count: 258
        
Say I have a simple object such as
class Something
{
   public int SomeInt { get; set; }
}
I have read that using immutable objects are faster and a better means of using business objects? If this is so, should i strive to make all my objects as such:
class ImmutableSomething
{
   public int SomeInt { get { return m_someInt; } }
   private int m_someInt = 0;
   public void ChangeSomeInt(int newValue)
   {
       m_someInt = newvalue;
   }
}
What do you reckon?
© Stack Overflow or respective owner