CHAPTER 3

image

Syntax

The pure and simple truth is rarely pure and never simple.

—Oscar Wilde

The previous chapters emphasized the similarities between C# and C++/CLI. Now we touch on the main areas where they differ and begin to understand why. These include additional or different keywords, separators, and operators.

Keywords and Separators

In C++, the additional keyword namespace is required when using a namespace (see Table 3-1).

Table 3-1. Namespaces in C# and C++/CLI

C#

C++/CLI

using System.Threading;

using namespace System::Threading;

System.Console.WriteLine("H");

System::Console::WriteLine("H");

Moreover, where C# uses dot ...

Get C++ 2013 for C# Developers,Second Edition 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.