I heard a bike that if I write like this int i = 0 , not System.Int32 i = 0 or

 using System; ....... Int32 i = 0; 

Some kind of optimization is happening *. Is there any difference between these options?

* Number of characters typed, etc. do not take into account.

Reported as a duplicate by Grundy , PashaPash members c # Nov 20 '18 at 13:54 .

A similar question was asked earlier and an answer has already been received. If the answers provided are not exhaustive, please ask a new question .

3 answers 3

No difference, int and Int32 will be the same after compilation in IL code. int is a keyword for c #, exactly like an Integer for VisualBasic , but both are System.Int32 .

    int is a primitive that is available in the C # compiler, while Int32 is an FCL type and therefore is available for all languages ​​that correspond to CLS.

      In C #, int is the simple type, the System.Int32 alias.

      There is only one case where mention of the type is valid, and mention of aliases is not. This is the nameof construction:

       // компилируется string name = nameof(Int32); // ошибка string name = nameof(int); 

      In all other cases, there is no difference between int , System.Int32 and using System + Int32 . - everything will turn into the same mention of the System.Int32 type in the resulting assembly.

      • one
        @Grundy shut down. - PashaPash
      • one
        In all other cases, there is no difference. What about (int)-1 and (System.Int32)-1 ? - PetSerAl 7:44
      • @PetSerAl hmm, did not know, thanks for the example. I will add in the answer as I will reach a stationary computer. - PashaPash