Click here to Skip to main content
13,142,065 members (55,054 online)
Rate this:
Please Sign up or sign in to vote.
See more:
Hi Guys!!!

whats difference between Auto-Implemented Properties and manual properties in c#?

for Example:
Manual Properties:

private int uno;
        public int Uno
            get { return uno; }
            set { uno = value; }

Auto Implemented Prop:

public string UserLeaveCount { get; set; }

Posted 6-Nov-12 22:21pm

1 solution

Rate this: bad
Please Sign up or sign in to vote.

Solution 1

Not much. Auto implemented properties are simply syntactic shorthand for the compiler. If you look at the assembly using a tool like ILSpy, you'll see that an auto implemented property actually gets converted to property + backing field at compile time.[^][^]

The only real-world difference is that a manual property can do things with the value before it is assigned or returned. An auto property just sets or returns the value.
Sarrrva 7-Nov-12 4:38am
thats fine jim, but i have a doubt about "there is no instance variable and how is it store and returned values?"

jim lahey 7-Nov-12 4:46am
where does it say that? BTW, if you're going to ask more questions, amend your original one or ask a fresh one. questions in the comments section tend to get overlooked.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy |
Web03 | 2.8.170915.1 | Last Updated 7 Nov 2012
Copyright © CodeProject, 1999-2017
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100