S
S
Student Hard Worker2021-07-07 21:40:10
C++ / C#
Student Hard Worker, 2021-07-07 21:40:10

When should you use properties and when should you use fields?

When should you use properties and not fields?
Except when we need to explicitly apply (implement) accessors instead of using automatic ?

public string Name { get; set; }
vs
public string name;


Why is the first option often used?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
H
HemulGM, 2021-07-07
@EugeneTypescript

Because it is customary to make properties public, not fields.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question