optional

There are 2 entries for the tag optional

More Versioning Fun With Optional Arguments

In my last blog post, I covered some challenges with versioning methods that differ only by optional parameters. If you haven’t read it, go read it. If I do say so myself, it’s kind of interesting. ;) In this post, I want to cover another very subtle versioning issue with using optional parameters. At the very end of that last post, I made the following comment. By the way, you can add overloads that have additional required parameters. So in this way, you are in the same boat as before. However, this can...

Versioning Issues With Optional Arguments

One nice new feature introduced in C# 4 is support for named and optional arguments. While these two features are often discussed together, they really are orthogonal concepts. Let’s look at a quick example of these two concepts at work. Suppose we have a class with one method having the following signature. // v1 public static void Redirect(string url, string protocol = "http"); This hypothetical library contains a single method that takes in two parameters, a required string url and an optional string protocol. The following shows...