If the following expression looks intimidating, it's because it is using a feature introduced in C# 6 and expanded in C# 7:
private HashSet<string> AllowedExtensions => new HashSet<string>(StringComparer.InvariantCultureIgnoreCase) { ".doc",".docx",".pdf", ".epub" }; private enum Extention { doc = 0, docx = 1, pdf = 2, epub = 3 }
The preceding example returns a HashSet of allowed file extensions for our application. These have been around since C# 6, but have been extended in C# 7 to include accessors, constructors, and finalizers. Let's simplify the examples a bit.
Assume that we had to modify the Document class to set a field for _defaultDate inside the class; traditionally, we ...