So, I was working on something that required a loop through enumerated types (in this case, go through the different repayment methods of a mortgage calculator)

public enum RepaymentMethod
  RepaymentOnly ,

To loop through this, use Enum.GetValues() to grab an array of the enumerations, and walk through it like this:

Array repaymentMethods = Enum.GetValues(typeof(RepaymentMethod));
foreach (RepaymentMethod method in repaymentMethods)
  calculator.RepaymentMethod = method;
  Assert.AreEqual(0, calculator.MonthlyPayments);
Need to find a lawyer for your business? Get in touch with my company Lexoo and we'll find you a great one for free.