3.4. Language Constructs, Syntax, and the API

This section compares the building blocks of C# and Java. We use the following categories:

  • Data types

  • Operators

  • Control flow statements

  • Exception support

  • Common objects (Object, String)

  • Common language elements

  • Collections library

  • Threading

  • Input/output

  • Namespaces and assemblies

  • What is missing from Java?

  • What is missing from C#?

3.4.1. Data Types

C# allows for both safe and unsafe code. You can use unsafe code to do the kind of pointer programming supported in C and C++. Safe code is what Java programmers are used to, and one of the reasons it is called safe is that type safety is guaranteed by the runtime for safe code. Table 3.3 compares some of the key points of similarity between Java and C# data types. ...

Get .NET for Java Developers: Migrating to C# now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.