static void Main(string[] args) { Console.WriteLine("Hello C#!"); Kilogram kg1 = new Kilogram(5); Kilogram kg2 = new Kilogram(10); Kilogram kg3 = kg1.Add(kg2); Kilogram kg4 = kg1 + kg2; Console.WriteLine(kg3); Console.WriteLine("연산자 오버로딩으로~" + kg4); }
public Kilogram Add(Kilogram target) { return(new Kilogram(this.mass + target.mass)); }