什么时候在C#中使用结构体?

搬运一条在Stackoverflow上的高分回答

 

  1. It logically represents a single value, similar to primitive types (integer, double, and so on).
  2. It has an instance size smaller than 16 bytes.
  3. It is immutable.
  4. It will not have to be boxed frequently.

豁然开朗

 

当然在进行P/Invoke时,都是需要使用结构体的。可以参考以下文章

https://www.cnblogs.com/zhaotianff/p/12510286.html

 

posted @ 2022-03-10 22:08  zhaotianff  阅读(319)  评论(0编辑  收藏  举报