Boxing Occurrence in C#

后端 未结 5 1079
清歌不尽
清歌不尽 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:43

    • Using the non-generic collections in System.Collections such as ArrayList or HashTable.

    Granted these are specific instances of your first case, but they can be hidden gotchas. It's amazing the amount of code I still come across today that use these instead of List and Dictionary.

提交回复
热议问题