Thursday, December 13, 2012

inner/nested partial classes

Another way inner/nested classes may be used is as partials. This would allow for the extension of a second partial elsewhere by the class wrapping the partial class. Maybe the Poop class does not normally hold a getsetter for IsCarryingParasites and it is extended for the Cat class like so:

namespace Whatever
{
   public class Cat {
      public Poop Poo { get; set; }
      public partial class Poop
      {
         public bool IsCarryingParasites { get; set; }
      }
   }
}

No comments:

Post a Comment