<分区>
当我在阅读this tutorial我注意到以下有关在 C# 中使用结构的性能提示:
Unless you need reference type semantics, a class that is smaller than 16 bytes may be more efficiently handled by the system as a struct.
我在 stackoverflow 中查找了类似的问题,并在 ADO.Net 中找到了一些关于性能最佳实践的问题。 , Networking , Streams ,但与C#(语言)中的性能最佳实践无关。
我想添加另一个关于使用整数类型的提示:
The runtime optimizes the performance of 32-bit integer types (Int32 and UInt32), so use those types for counters and other frequently accessed integral variables.