Trying to do everything by the book, is this correct?:
public class JollyHockey
{
public string AnotherCoolProperty { get { return anotherCoolProperty; } }
string anotherCoolProperty;
public JollyHockey(string anotherCoolProperty)
{
this.anotherCoolProperty = anotherCoolProperty;
}
}
Or do some people use underscores for the private class variables?
Some people (including myself) prefix private class variables with an underscore (simply as a visual indication of what is being used where).
This is mainly a personal (or team) level style consideration and you can use what you want (or what your team has standardized on).
Just be sure you’re consistent!
For what it’s worth, you could also use auto-properties for your example: