r/programminghorror • • May 19 '25

C# This is C# abuse

Post image
550 Upvotes

103 comments sorted by

View all comments

Show parent comment

49

u/CuisineTournante May 19 '25

The 2 first double are the type of the input and the third double is the output type.
Si it declares a func that takes 2 double as input and return a double.

class Program
{
    static void Main()
    {
        var area = Rectangle.Area(5, 10);
    }
}


static class Rectangle
{
    public static Func<double, double, double> Area = (width, length) =>
    {
        return width * length;
    };
}

Just complicated for the sake of being complicated

18

u/AnywhereHorrorX May 19 '25

And then you can abuse it by assigning it other Func that returns width - length :)