|
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.
.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 | Pertains to all database functionality. |
System.IO | Comprises file I/O. |
System.Reflection | 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 | Supports all GDI, bitmaps, icons, and fonts. |
System.Runtime.InteropServices | 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.
Microsoft .NET Types | Visual Basic | 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 |
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 |
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");
|