Understanding the Common Type Specification (CTS)


A Type refers to a collection of classes, interfaces, delegates, and structures supported by the Common Language Runtime. Microsoft .NET also allows you to create your own user-defined types. Moreover, you can group the user-defined types into unique namespaces. As previously stated, all objects derive from System.Object. Table 5-4 provides information about the .NET namespaces.

Table 5-4: .NET Namespaces

.NET Namespace

Meaning

System

Contains a collection of classes referencing primitive types, math manipulations, garbage collection, debugging, etc.

System.Collections

Defines container objects, for example, ArrayLists, Queues, etc.

System.Data.Oledb
System.Data
System.Data.Common
System.Data.SqlClient

Pertains to all database functionality.

System.IO

Comprises file I/O.

System.Reflection
System.Reflection.Emit

Supports IL code and assembly examination at runtime. System.Reflection.Emit allows you to create dynamic assemblies on the fly.

System.Net

Hosts Types relating to network application design.

System.Diagnostics

Facilitates language-agnostic diagnosis.

System.Drawing.System.Drawing2D
System.Drawing.Printing

Supports all GDI, bitmaps, icons, and fonts.

System.Runtime.InteropServices
System.Runtime.Remoting

Offers interoperability between managed and unmanaged code, for example, COM Servers, Win32 DLLs, etc.

System.Threading

Facilitates multithreading. This includes Types Mutex, Timeout, and Thread.

System.Security

Supports .NET security, for example, CodeAccessPermissions.

System.Windows.Forms

Enables dialog box construction, windows, MessageBox.Show, etc.

System.Web

Provides support for all web services, web application development, and ASP.NET (the presentation layer).

System.XML

Contains a set of classes representing core XML primitives and types, thereby facilitating interaction with XML data.

In Visual Basic .NET, the CTS Structure replaces VB Types. Whereas VB 6.0 supported the Type keyword, thereby enabling developers to create user-defined types, the .NET keyword Structure defines numerical types, for example, complex numbers. As observed in our System.Reflection.Emit runtime application, DynamicAssembly, the Common Type Specification provides information on all data types supported by the runtime. Simply put, the CTS describes precisely how the disparate data types interact with each other courtesy of the assembly manifest, both at design time and runtime. This demonstrates how .NET reusable binaries can intermingle across all platforms targeting the Framework. Structures implement a great number of interfaces.

Note

The list of tree icons for viewing an assembly, provided in the earlier section “Reading Metadata,” displayed a magenta rectangle marked “S.” This icon denotes a static method, meaning the method is sealed. Therefore, structures may not derive from other base types.

Before turning our discussion to .NET modules, let’s finish this examination of CTS Types. Table 5-5 displays the CTS intrinsic Types. You can see how all languages share the same data type declared and defined in Microsoft .NET class libraries.

Table 5-5: Microsoft .NET Intrinsic Types and Their Representations in Other Languages

Microsoft .NET Types

Visual Basic
.NET Type Representation

C# Type Representation

C++ with Managed Extensions Representation

System.Byte

Byte

byte

char

System.SByte

Not supported

sbyte

signed char

System.Int16

Short

short

short

System.Int32

Integer

int

int or long

System.Int64

Long

long

_64

System.UInt16

Not supported

ushort

unsigned short

System.UInt32

Not supported

uint

unsigned int or
unsigned long

System.UInt64

Not supported

ulong

unsigned_int64

System.Single

Single

float

float

System.Double

Double

double

double

System.Object

Object

object

Object

System.Char

Char

char

_wchar_t

System.String

String

string

String

System.Decimal

Decimal

decimal

Decimal

System.Boolean

Boolean

bool

bool

.NET Modules

A .NET module is a representation of a class type. Public functions, subroutines, and variables defined within module scope are shared members. They are visible to an entire application.

Note

You may not create modules. For an example, refer to our IFCE Assembly module:

ModuleBuilder module = assembly.DefineDynamicModule
("MyIFCEAssembly", "MyIFCEAssembly.dll");




.NET & J2EE Interoperability
Microsoft .NET and J2EE Interoperability Toolkit (Pro-Developer)
ISBN: 0735619220
EAN: 2147483647
Year: 2004
Pages: 101
Authors: Simon Guest

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net