Filed under Computers, Programming, Software
I am reading this document about the C# language.
Here are a list of features in C# that improve on how C++ works…
|Reference to a class in another file of a project requires an include file||No include file needed|
|Reference to a class in an external DLL requires an include file and the DLL’s .LIB file passed to the linker||No .LIB file needed. |
Add a reference to the DLL in the build(example: csc /r:external.dll helloworld.cs)
|Exported symbols must use declspec or .DEF file||No declspec or .DEF file. |
Public symbols are exported, private/protected are not.
”internal” symbols are only available within module.
|Referencing a class/structure before it is declared requires forward declaration||Forward declaration not needed. |
Declaration order is insignificant.
Switching to Unicode/16-bit text requires:
Unicode is the native string format
|NULL is a concept, not part of the language. It is typically defined as 0 and thus is the equivalent of 0.||null is a keyword. It is not equivalent to 0.|
|Basic data types (int, float, char, etc.) cannot accept a “null” value. Only pointers can have a “null” value.|| |
|No support for “foreach”||foreach keyword for iterating over a collection|
|Support for try and catch. |
No support for "finally”
|try-catch-finally support. |
finally is always called, regardless of exception or not
|No notification of overflow operations. |
unsigned x = UINT_MAX;
// x == 0 now, no exception thrown
|Using checked/unchecked you can get overflow or exception thrown behavior|
|No native support for critical sections||lock keyword for critical sections|
|For switch statements, break is optional.||break is required (to prevent bugs from accidentally forgetting to add break)|
|No built-in documentation||XML documentation via “///”- prefixed comment. Used by IntelliSense in Visual Studio|
|Cannot split the definition of a class across multiple files||Partial classes allow breaking up a source file (useful when multiple people are working on a class or when part of a class is auto-generated)|
|No support for mixing versions of libraries||Can mix library versions without breaking existing code.|
|Developer must manage deletion of memory and potential issues from reading/writing to invalid memory|| |
|Types do not share a common root||All types derived from base “object”|