4 ms·
Isn't the first C# example (the class) a pessimization? Why not e.g. public class CircleMeasurement { public double Diameter { get; private set
by masklinn 14y ago
Isn't the first C# example (the class) a pessimization? Why not e.g.
public class CircleMeasurement
{
public double Diameter { get; private set }
public double Area { get; private set }
public double Circumference { get; private set }
public CircleMeasurement(double diameter, double area, double circumference)
{
Diameter = diameter;
Area = area;
Circumference = circumference;
}
}
Arguably there's still a fair bit of repetition due to the constructor, compared to the F# code (and I'm not sure object initializers can be used with private-set properties), but a third of the repetitions have been skipped through implicit backing fields.
- sklivvz1971 14y agoAlso most of that code can be written automatically with Resharper...
- Rickasaurus 14y agoAnd he didn't even implement equality and comparison yet!