Scarlett
Scarlett
CC#
Created by Scarlett on 5/3/2023 in #help
✅ help!
i need to write a program in a winforms app that takes a user input of radius to calculate the area and diameter of a circle. There must be a class separate from the main file with fields, properties and constructor. I have most of the program written, but I am struggling to understand how to pass the calculated area and diameter to the labels on my form. The program runs, but crashes when the button to calculate is pressed. The labels im passing the values too is label6 and label7.
Here is the code for the class file: public class Circle { static double _radius; static double _diameter; static double _area; public static double Area { get { return _area; } } public static double Diameter { get { return _diameter; } } public static double Radius { get { return Radius; } set { Radius = value; } } public Circle() { Radius = 1; } public Circle(double radius) { _radius = Radius; _area = Radius * Radius * Math.PI; _diameter = Radius * 2 }
683 replies