| interval/static-factory-method/Interval-after.cs - A better solution with static factory methods. | Lecture 4 - slide 28 : 29 Program 4  | 
using System;
using System.Collections;
public struct Interval{
  private readonly int from, to;
  private readonly bool empty;
  // Construct a non-empty interval [from - to] if empty is false.
  // Else construct an empty interval (from and to are not used). 
  private Interval(int from, int to, bool empty){
    this.empty = empty;
    this.from = from;
    this.to = to;
  }
  public static Interval MakeInterval(int from, int to){
    return new Interval(from,to,false);
  }
  public static Interval MakeEmptyInterval(){
    return new Interval(0,0,true);
  }
  // Other Interval operations not shown   
}