This article describes the usage of C# operator overloading. Share it for your reference. The specific analysis is as follows:
public class Plane { public virtual double TopSpeed() { return 300.0D;} public static bool operator>(Plane one, Plane two) { return () > (); } public static bool operator<(Plane one, Plane two) { return () < (); } } class Jet : Plane { public override double TopSpeed() { return 900.0D; } public override string ToString() { return "I'm a Jet"; } } class Airport { [STAThread] static void Main(string[] args) { Plane plane = new Jet(); ("plane's top speed: {0}",()); Jet jet = new Jet(); ("jet's top speed: {0}",()); ("Plane > Jet = {0}", plane > jet); (); } }
I hope this article will be helpful to everyone's C# programming.