Ive been researching and I am a little stuck on finding the right answer.
Lets say I have a c# class with auto properties. I want to have some of these properties calculated based of the properties that a user will change. I understand that you can use a constructor to do this calculation on creation of a new object.
What I am trying to find out is, in a web api does the class constructor get called on an update? Do i do the following or create customer setters?
eg
class myclass
{
public int Num1 { get; set; }
public int Num2 { get; set; }
public int Num3 { get; set; }
public int Num4 { get; set; }
//these get changed when values above get changed by API
public int result1 { get; set; }
public int result2 { get; set; }
public int result3 { get; set; }
//constructor
public myClass()
{
result1 = Num1 + Num2;
result2 = Num3 + Num2;
result3 = Num4 + Num2;
{
}
result1to be a read-only property?