I’m writing/written a value type struct and was wondering if there was a guide that contains a standard template for method signatures and interface implementation. I thought I’d start by looking at the System.Double documentation:
public struct Double : IComparable, IFormattable,
IConvertible, IComparable<double>, IEquatable<double>
Is there like a standard approach to creating a value type struct?
Thanks
There isn’t a template per se, but there are certainly guidelines. The most important guideline is value types should be immutable. Only violate this guideline if you know exactly what you are doing.
In addition to the guidelines listed in the MSDN article I linked to I also recommend:
Object.EqualsandObject.GetHashCode.==and!=.