C# - Using implicit operator overloads to keep your API discoverable and open

added by danielwertheim
5/4/2014 5:17:54 PM


Recently I had the need to provide consumers of a SDK with a set of possible values that could be passed to a constructor of a member in a SDK library. The "list" of values was semi-static. With this, I mean that I also needed to treat this list of possible values as a "current version" and still allow the consumer to pass a somewhat arbitrary value. Why? Because the remote service could come to allow more values before the SDK has had a chance to be updated. There are (as always) many solutions, but lets look at one using simple factory methods and a implicit operator overloads.