Dot Net Gotcha #1 – List versus Collection constructor
Don’t Google it! Do you know (without Googling it) what will this console application display when executed? If you try to think logically, you expect that both List and Collection will contain numbers from 1 to 6 when they are displayed, right? Wrong, otherwise this would not be a proper gotcha 😉 Here is the actual output of the application (surprise, surprise): Do you know why? Answer is actually very simple. If you check the MSDN documentation for Collection constructor that accepts generic IList you will see this text: Initializes a new instance of the Collection class as a wrapper for…