Tagged Questions
12
votes
5answers
6k views
Multiple classes in a single .cs file - good or bad?
Is it advisable to create multiple classes within a .cs file or should each .cs file have an individual class?
For example:
public class Items
{
public class Animal
{
}
public class ...
36
votes
15answers
3k views
Are #regions an antipattern or code smell?
In C# code it allows the #region/#endregion keywords to made areas of code collapsible in the editor. Whenever I am doing this though I find it is to hide large chunks of code that could probably be ...
5
votes
10answers
884 views
Property-coalescing operator for C#
The null-coalescing operator in c# allows you to shorten the code
if (_mywidget == null)
return new Widget();
else
return _mywidget;
Down to:
return _mywidget ?? new Widget();
I ...