Skip to content

Instantly share code, notes, and snippets.

@hmemcpy
Last active December 14, 2015 03:48
Show Gist options
  • Save hmemcpy/5023336 to your computer and use it in GitHub Desktop.
Save hmemcpy/5023336 to your computer and use it in GitHub Desktop.
Who knew static initializers depend on the order?
public static readonly string[] MyPaths = GetAllPaths("path1", "path2");
static readonly string[] AllExtensions = new[] { ".htm", ".html", ".sshtml" };
private static string[] GetAllPaths(params string[] viewLocations)
{
// this will throw a NRE since AllExtensions is null!
return viewLocations.SelectMany(view => AllExtensions.Select(extension => view + extension)).ToArray();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment