In order to eliminate some redundancy or increase readability, you can shrink the way you instantiate classes.
See the example below:
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class MyClass | |
{ | |
// Shorthand instantiation | |
private readonly List<Foo> foos = new(); | |
// Explicit instantiation | |
private readonly List<Bar> bars = new List<Bar>(); | |
} |
Top comments (0)