Friday, March 29, 2013

Finalizers are syntaxically like constructors that start with a tilde.

This suggests that you can use them to dispose of open connections and do the sort of things that you should probably be doing with using statements instead. I read about these in C# 4.0 in a Nutshell and decided I didn't care. I thought of them again yesterday when two guys a cube away were having a fascinating conversation about interview questions that went into internal and protected internal accessibilities. I interrupted and asked questions about my poor understanding of internal and my understanding got better. The same guys went on to talk about destructors (finalizers) and I wondered anew if I should care. I looked into them again this morning and have decided that using statements are cooler. You know?

namespace MvcApplication1.Models
{
   class Foo
   {
      internal string Bar;
      internal Foo()
      {
         Bar = "started";
      }
      ~Foo()
      {
         
//whatever
      }
   }
}

No comments:

Post a Comment