In order to be eligable for interning, a type must be:
1) A reference type. Interning uses the reference of an object, to place have it point to a general location instead of the area in the heap that is allocated to the object. Since value types are just addressed by value, there would be no way to intern them.
2) Immutable. A type that is interned can be referenced by multiple objects that were meant to be independent and the user may not even know that they are interned. Therefore, the value of the object cannot change.
Below is a list of the basic CLR types and their corresponding C# alias. All of the types, except System.String are value types. All of them, except System.String are therefore also mutable. Because of this, only System.String would be a candidate for interning (and yes, it is the only class that is interned).
- System.Boolean bool
- System.SByte sbyte
- System.Int16 short
- System.Int32 int
- System.Int64 long
- System.Byte byte
System.UInt16 ushort
- System.UInt32 uint
- System.UInt64 ulong
System.Single float
- System.Double double
- System.Char char
System.String string
- System.DateTime N/A
- System.Decimal decimal