Advertisement
Intermediate .NET, CLR & Runtime

What is the Common Type System (CTS), and how does it enable interoperability between different .NET languages?

Short answer

The Common Type System defines a shared set of types and rules for how types are declared, used, and managed that every .NET language's compiler must map its own type system onto, ensuring a C# class, an F# record, and a VB.NET class all ultimately produce compatible…

Save .NET mock interview
Advertisement
AModel answer
The Common Type System defines a shared set of types and rules for how types are declared, used, and managed that every .NET language's compiler must map its own type system onto, ensuring a C# class, an F# record, and a VB.NET class all ultimately produce compatible, interoperable IL-level types that any other .NET language can consume seamlessly without translation layers.
// C# class
public class Point { public int X { get; set; } }

// F# can consume it directly since both compile to compatible CTS-conforming IL
let p = Point(X = 5)
Real-world example
A data science team writes core numerical algorithms in F# for its expressive functional syntax, while the surrounding web API and business logic are written in C#, with both languages interoperating seamlessly because they share the CTS.
Likely follow-ups
  • What's the difference between the CTS and the Common Language Specification (CLS)?
  • Why can't all CTS features be expressed in every .NET language equally?
Related topics