I know that in C # you can easily create accessors for a data type, for example by doing the following:
public class DCCProbeData { public float _linearActual { get; set; } public float _rotaryActual { get; set; } }
However, my colleague advised me to do it like this:
public class DCCProbeData { private float _linearActual = 0f; public float LinearActual { get { return _linearActual; } set { _linearActual = value; } } private float _rotaryActual = 0f; public float RotaryActual { get { return _rotaryActual; } set { _rotaryActual = value; } } }
My way seems simpler and more concise. What are the differences and benefits of this anyway?
thanks
Edit Only a note, my colleague was able to create code for the “second path” using the “Refactor” option in the “Class Details” panel, which was most easily found in the diagram file. This makes it easy to add many properties without having to manually create accessors.
source share