Although it has some elements derived from Visual Basic and Java, C++ is C#'s closest relative.
In an important change from C++, C# code does not require header files. All code is written inline.
As touched on above, the .NET runtime in which C# runs performs memory
management, taking care of tasks like garbage collection. Because of
this, the use of pointers in C# is much less important than in C++.
Pointers can be used in C#, where the code is marked as 'unsafe', but
they are only really useful in situations where performance gains are at
an absolute premium.
Speaking
generally, the 'plumbing' of C# types is different from that of C++
types, with all C# types being ultimately derived from the 'object'
type. There are also specific differences in the way that certain common
types can be used. For instance, C# arrays are bounds checked unlike in
C++, and it is therefore not possible to write past the end of a C#
array.
C#
statements are quite similar to C++ statements. To note just one
example of a difference: the 'switch' statement has been changed so that
'fall-through' behavior is disallowed.
As
mentioned above, C# gives up on the idea of multiple class inheritance.
Other differences relating to the use of classes are: there is support
for class 'properties' of the kind found in Visual Basic, and class
methods are called using the Operator rather than the :: operator.
0 comments:
Post a Comment