22.3. Another example of operator overloading

Just for developers who enjoy dabbling with matrices, here's another full example. [4]

[4] You can skip this if you have understood the previous example. You need to understand matrix mathematics to appreciate what is going on here. (Time to search for that old high school math textbook!)

 1: using System; 2: 3: // class represents a 2 " 2 matrix 4: class Matrix{ 5: 6: // these 4 fields represent the 4 values in the 2 " 2 matrix 7: public float TopLeft; 8: public float TopRight; 9: public float BottomLeft; 10: public float BottomRight; 11: 12: // constructor 13: public Matrix 14: (float TopLeft, float TopRight, float BottomLeft, float BottomRight){ 15: this.TopLeft = TopLeft; 16: this.TopRight = TopRight; ...

Get From Java to C#: A Developer's Guide now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.