Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 439429
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T20:46:29+00:00 2026-05-12T20:46:29+00:00

Recently, after reading a lot of tutorials around the Internet, I’ve noticed that some

  • 0

Recently, after reading a lot of tutorials around the Internet, I’ve noticed that some developers skips writing the fields in their model classes and just go with properties, like this:

public class MyClass
{
    public string MyProperty { get; private set; }
}

What exactly is the benefit of doing this, apart from writing less code that is? While I do realize that the setter is private, isn’t there some kind of security issues when you don’t specify your private fields? In other words: what’s the best practice here? Writing model classes without fields and related properties, or just go with these public properties without the fields?

Thanks in advance,

Bo

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-12T20:46:30+00:00Added an answer on May 12, 2026 at 8:46 pm

    In c# 3.0 and above, the compiler will put the local variables into the MSIL for you. It makes the code easier to read and more maintainable (less variables to keep track of, etc).

    There should be no security issue because internally it is creating locally scoped member variables.

    See Microsoft’s documentation for more info.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Recently I noticed (after others have extended the project) that the compile time significantly
I recently started reading about ASP.net MVC and after getting excited about the concept,
I had recently a problem with oom-killer starting to kill processes after some time.
E-Texteditor recently announced going open-source with their open company model. However after reading through
After reading this question I attempted to clean out my workspace and found that
After reading about the System.Diagnostics.Contracts.Contract static class that has been influenced by the awesomeness
After reading about valHooks in a jQuery defect and more recently seen in a
I recently came across the subject of exact real arithmetic after reading this paper
Recently, I've got a dangerous idea into my head after reading this blog post.
I recently read on Meta about some browser not flushing their cache even after

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.