C # -Generics - CLS or IL?

Are generics parameterized IL or part of CLS?

+3
source share
2 answers

They are part of the CLI and are described in detail in the standard (ECMA 335). IL uses special instructions and formats that directly encode various common operations. Thus, the general code is directly compiled into CIL, which itself uses type variables.

+5
source

To extend Barry's answer, can you see int? x = 5; in IL:

IL_0001:  ldloca.s    00 
IL_0003:  ldc.i4.5    
IL_0004:  call        System.Nullable<System.Int32>..ctor
+1
source

Source: https://habr.com/ru/post/1715918/


All Articles