CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 1 of 1
  1. #1
    Join Date
    Jul 2001
    Location
    Sunny South Africa
    Posts
    11,283

    .NET Framework CLR: What is the Common Type System?

    Q: What is the Common Type System?

    A: The Common Type System (CTS) defines how types are declared, used and managed in the runtime, and is also an important part of the runtime's support for cross-language integration.


    • What functions does the Common Type System perform?


      • Establishes a framework that helps enable cross-language integration, type safety, and high performance code execution.

      • Provides an object-oriented model that supports the complete implementation of many programming languages.

      • Defines rules that languages must follow, which helps ensure that objects written in different languages can interact with each other.




    • What types does the Common Type System support?


      • Value types

        Value types directly contain their data, and instances of value types are either allocated on the stack or allocated inline in a structure. Value types can be built-in (implemented by the runtime), user-defined, or enumerations. For a list of built-in value types, see the .NET Framework Class Library.

      • Reference types

        Reference types store a reference to the value's memory address, and are allocated on the heap. Reference types can be self-describing types, pointer types, or interface types. The type of a reference type can be determined from values of self-describing types. Self-describing types are further split into arrays and class types. The class types are user-defined classes, boxed value types, and delegates.




    • Can I have an example of the difference between value types and reference types?

      The following example shows the difference between reference types and value types:


      Code:
      Imports System
      
      Class Class1
          Public Value As Integer = 0
      End Class 'Class1
      
      Class Test
          
          Shared Sub Main()
              Dim val1 As Integer = 0
              Dim val2 As Integer = val1
              val2 = 123
              Dim ref1 As New Class1()
              Dim ref2 As Class1 = ref1
              ref2.Value = 123
              Console.WriteLine("Values: {0}, {1}", val1, val2)
              Console.WriteLine("Refs: {0}, {1}", ref1.Value, ref2.Value)
          End Sub 'Main
      End Class 'Test

    • What would the output be of the above example?

      Values: 0, 123
      Refs: 123, 123



    Last edited by Andreas Masur; December 22nd, 2005 at 05:18 PM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured