Cool Things in .NET
C# Language
- Explicit cast automatically raises exception if run-time type conversion is not possible.
- Use of the “is” keyword in C# to check run time type.
- Fields in a class can be initialised inline. ex: class blob { int member = 2; }
You don't have to write the initialisation in the constructor. One of those things you instinctively tried to do in C++.
CLR
- Documentation: list of class members include inherited members (which is very convenient, no need to navigate through the base classes)
- C# supports floating point Point class. The MFC CPoint only supports integers.
- When instantiating an object, the memory allocated to it is automatically zeroed out.
- String interning: the CLR automatically groups equivalent strings in the same memory location.
IDE:
- When adding a source file to a project (.cs file), if the source file is outside the solution directory then it is automatically copied to the solution directory.
- When deleting a source file from the project, the actual file on disk is deleted as well.
- It is possible to add an external file to a project by creating a link rather than copying it (choose Link File from the Open combo-button in the Add Existing Item window).
Intellisense:
- To override a base method, just type protected override and choose the method from the Intellisense window.
- When creating new event handler: after typing +=, pressing TAB automatically adds the typical delegate associated with event. Pressing TAB again inserts event handler.
