I am admittedly inexperienced with C#/OOP, but I recently came across this code and it feels incorrect to me even though it does appear to functionally work. The code is from a console application.
namespace ConsoleApp
{
class Program
{
static private double Theta{ get; set; }
static void Main(string[] args)
{
...
var thetaString = Console.ReadLine();
if (!String.IsNullOrEmpty(thetaString))
Theta = Math.PI * Double.Parse(thetaString) / 180.0;
...
}
}
}
If I remove the static declaration from Theta, it will no longer compile. If I remove the {get; set}, it functions just as it did previously. What is this code doing? What is the significance of the accessors?