Boxing Occurrence in C#

后端 未结 5 1077
清歌不尽
清歌不尽 2020-11-30 18:15

I\'m trying to collect all of the situations in which boxing occurs in C#:

  • Converting value type to System.Object type:

    struct          
    
    
            
5条回答
  •  借酒劲吻你
    2020-11-30 18:39

    Adding any value type value into the ArrayList causes boxing:

    ArrayList items = ...
    numbers.Add(1); // boxing to object
    

提交回复
热议问题