Defining functions for structs

image_pdfimage_print
   
 

using System;
struct Dimensions {
    public double Length;
    public double Width;
    Dimensions(double length, double width) { Length = length; Width = width; }

    public double Diagonal {
        get {
            return Math.Sqrt(Length * Length + Width * Width);
        }
    }
}