Robert MacLean - http://www.sadev.co.za Setups the framework for a struct - with the methods that the offical snippet skips. http://www.sadev.co.za C# struct GetHashCode Equals Equalality operator == Inequalality operator != structc Expansion Struct Complete
name Struct name MyStruct struct $name$ { //TODO: Add properties, fields, constructors etc... /// /// Returns a hash code for this instance. /// /// /// A hash code for this instance, suitable for use in hashing algorithms and data structures like a hash table. /// public override int GetHashCode() { int valueStorage = 0; object objectValue = null; foreach (PropertyInfo property in typeof($name$).GetProperties()) { objectValue = property.GetValue(this, null); if (objectValue != null) { valueStorage += objectValue.GetHashCode(); } } return valueStorage; } /// /// Determines whether the specified is equal to this instance. /// /// The to compare with this instance. /// /// true if the specified is equal to this instance; otherwise, false. /// public override bool Equals(object obj) { if (!(obj is $name$)) return false; return Equals(($name$)obj); } /// /// Equalses the specified other. /// /// The other. /// public bool Equals($name$ other) { //TODO: Implement check to compare two instances of $name$ $selected$$end$ return true; } /// /// Implements the operator ==. /// /// The first. /// The second. /// The result of the operator. public static bool operator ==($name$ first, $name$ second) { return first.Equals(second); } /// /// Implements the operator !=. /// /// The first. /// The second. /// The result of the operator. public static bool operator !=($name$ first, $name$ second) { return !first.Equals(second); } } ]]>