本文介绍了C#结构体使用技巧?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我喜欢使用结构很多。
所以阅读本的,还有没有其他问题,我应该有反对使用他们所有的时间
另请参见:
解决方案
You should make the following considerations about structs:
- structs should be immutable (mutable structs are not intuitive and unpredictable)
- structs always have a default (public parameterless) constructor that cannot be changed
- struct size should not exceed 16 bytes
- the
Equals
andGetHashCode
methods should be overriden for better performance - implementing the
IEquatable<T>
interface is recommended - redefining and
==
and the!=
operators is also recommended
这篇关于C#结构体使用技巧?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!