Best practice for class constructors?
Hello there.
I'm creating a class with one private and one public variable. I am a little unsure how the constructor should work when this is the case. As an example:
Does it make sense to declare them first, and then assign them in the initializor? Also, are you supposed to add
I am also unsure what the best practice is for variable names in C#. Some places I have seen names with capital first letter, other times I see something like
I'm creating a class with one private and one public variable. I am a little unsure how the constructor should work when this is the case. As an example:
Does it make sense to declare them first, and then assign them in the initializor? Also, are you supposed to add
{ get; set; } to the class variable when it's also part of the constructor?I am also unsure what the best practice is for variable names in C#. Some places I have seen names with capital first letter, other times I see something like
exampleVariable. I come from Python, where we use _variable_name for private variables, do you also use the underscore in C#?