static void Main(string[] args) { //print using delegate Minimum min = Smallest; Console.WriteLine("Delegate values--------------------------------------------"); Console.WriteLine($" Shortest string: {min("Apple", "Banana", "Cherry")}"); AvgGrade avgGrade = AverageGrade; avgGrade(98.9, 92, 89.1); Console.WriteLine(""); //3 string parameters to input and 1 return string type Func <string, string, string, string> func1; //only 3 double and no returning type Action <double, double, double> act1; //built-in delegate func1 = Smallest; //Func act1 = AverageGrade; //Action //print using with Predicate Console.WriteLine("Built-in Delegate values------------------------------------"); Console.WriteLine($" Shortest string: {Smallest("Korea", "Canada", "UnitedKingdom")}"); act1(60, 70, 80); Console.WriteLine(""); }
/// <summary> /// Gets the hash code /// </summary> /// <returns>Hash code</returns> public override int GetHashCode() { unchecked // Overflow is fine, just wrap { var hashCode = 41; // Suitable nullity checks etc, of course :) if (Id != null) { hashCode = hashCode * 59 + Id.GetHashCode(); } if (Name != null) { hashCode = hashCode * 59 + Name.GetHashCode(); } if (ClimbCategory != null) { hashCode = hashCode * 59 + ClimbCategory.GetHashCode(); } if (ClimbCategoryDesc != null) { hashCode = hashCode * 59 + ClimbCategoryDesc.GetHashCode(); } if (AvgGrade != null) { hashCode = hashCode * 59 + AvgGrade.GetHashCode(); } if (StartLatlng != null) { hashCode = hashCode * 59 + StartLatlng.GetHashCode(); } if (EndLatlng != null) { hashCode = hashCode * 59 + EndLatlng.GetHashCode(); } if (ElevDifference != null) { hashCode = hashCode * 59 + ElevDifference.GetHashCode(); } if (Distance != null) { hashCode = hashCode * 59 + Distance.GetHashCode(); } if (Points != null) { hashCode = hashCode * 59 + Points.GetHashCode(); } return(hashCode); } }
/// <summary> /// Returns true if ExplorerSegment instances are equal /// </summary> /// <param name="other">Instance of ExplorerSegment to be compared</param> /// <returns>Boolean</returns> public bool Equals(ExplorerSegment other) { if (ReferenceEquals(null, other)) { return(false); } if (ReferenceEquals(this, other)) { return(true); } return (( Id == other.Id || Id != null && Id.Equals(other.Id) ) && ( Name == other.Name || Name != null && Name.Equals(other.Name) ) && ( ClimbCategory == other.ClimbCategory || ClimbCategory != null && ClimbCategory.Equals(other.ClimbCategory) ) && ( ClimbCategoryDesc == other.ClimbCategoryDesc || ClimbCategoryDesc != null && ClimbCategoryDesc.Equals(other.ClimbCategoryDesc) ) && ( AvgGrade == other.AvgGrade || AvgGrade != null && AvgGrade.Equals(other.AvgGrade) ) && ( StartLatlng == other.StartLatlng || StartLatlng != null && StartLatlng.Equals(other.StartLatlng) ) && ( EndLatlng == other.EndLatlng || EndLatlng != null && EndLatlng.Equals(other.EndLatlng) ) && ( ElevDifference == other.ElevDifference || ElevDifference != null && ElevDifference.Equals(other.ElevDifference) ) && ( Distance == other.Distance || Distance != null && Distance.Equals(other.Distance) ) && ( Points == other.Points || Points != null && Points.Equals(other.Points) )); }