What are the CTS and CLS?

.NET Framework & CLR Runtime Intermediate 1–2 Yrs2–3 Yrs Conceptual 1 min read

Quick Answer

The CTS (Common Type System) defines how types are declared and used in the runtime, so all .NET languages share one type model. The CLS (Common Language Specification) is a subset of CTS rules that a library should follow to be usable from any .NET language (e.g. don't expose uint in a public API — VB.NET historically couldn't consume it).

The CTS is the runtime's type model — it's what makes a C# int and a VB.NET Integer literally the same System.Int32, so languages can pass objects to each other. The CLS is a smaller set of rules a library follows so it can be consumed from any .NET language — the classic example is not exposing unsigned integers in a public API because some languages couldn't use them. You mark an assembly [CLSCompliant(true)] and the compiler warns you if you break the rules. It matters less now that everyone's writing C#, but it's still good practice for a library.

  • CTS is why an int in C# and an Integer in VB.NET are the same System.Int32.
  • CLS compliance matters for shared libraries: avoid unsigned types, don't rely on case-only-different identifiers, etc. Mark with [assembly: CLSCompliant(true)] to get compiler warnings.
  • Less of a concern today when almost everything is C#, but still relevant for widely reused libraries.