using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Diagnostics; /** * * * */ class HelloWorld { class Student { public decimal price{get;set;} //定义重载符号操作内容 public static decimal operator -(Student s1, Student s2) { return s1.price - s2.price; } } static void Main(string[] args) { //重载符号使用 Student s1 = new Student(); s1.price = 100; Student s2 = new Student(); s2.price = 500; Console.WriteLine(s1-s2); } }