Skip to content

Instantly share code, notes, and snippets.

@jhominal
Created July 17, 2013 08:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jhominal/6018805 to your computer and use it in GitHub Desktop.
Save jhominal/6018805 to your computer and use it in GitHub Desktop.
class Transaction {}
class ServiceCharge : Transaction {}
class Sale : Transaction {}
interface IChargable<out T> where T : Transaction
{
Transaction Charge();
}
class BusinessService : IChargable<ServiceCharge>
{
public ServiceCharge Charge()
{
return new ServiceCharge();
}
}
class Product : IChargable<Sale>
{
public Sale Charge()
{
return new Sale();
}
}
class Program
{
static void Main()
{
var chargables = new IChargable<Transaction>[]
{
new BusinessService(),
new Product()
};
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment