Tuesday, September 25, 2012

How do C# partial classes find their dance partners?

This sure makes partial classes in C# look easy. It looks like any classes of the same name in the same namespace will be married together by way of the partial keyword where they would otherwise cause a compilation error!

public partial class AIPlayer
{
   public AIPlayer()
   {
      
//whatever
   }
}
 
public partial class AIPlayer
{      
   public Move GetMove()
   {
      
//whatever
   }
}

 
 

In my googling, I found this showing off the VB way which made me cringe!

No comments:

Post a Comment