How to create a stack overflow

If you are doing this, Stop. It will cause a stackoverflow everytime ;) Just something I saw in a code review that made me laugh. It was an honest mistake...

public class MyClass
{
   public string
MyProperty
   {
      get{return
MyProperty;}
      set{MyProperty=value
;}
   }
}

1 Comment

  • This is really easy to fall into, if you dont have your private field defined yet.



    I typically reference all my class variables with this, and when you do that without defining the private field, no matter what you do (ie: typing it all out in lowercase), VS.NET will correct the case for you.



    Grrr...

Comments have been disabled for this content.