Are we supposed to use properties or private fields in Blazor code behind classes?

Viewed 537

In Blazor, certain things like injected objects and parameters must use properties, that part is clear.

But what about those page-specific variables, such as data/DTOs and misc strings/booleans etc used to control the page content and flow?

Is it better to use automatic properties with these all the way (public or private?) or private fields?

I'm asking this because in the various examples, tutorials and documentations related Blazor, use of both properties and fields are all over the place. I cannot seem to find any official best-practice guides on this.

0 Answers
Related