Click here to Skip to main content
15,884,298 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi Guys!!!

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

for Example:
Manual Properties:

C#
private int uno;

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


Auto Implemented Prop:

C#
public string UserLeaveCount { get; set; }



regards
sarva
Posted

1 solution

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.

http://msdn.microsoft.com/en-us/library/bb384054.aspx[^]

http://ilspy.net/[^]

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.
 
Share this answer
 
Comments
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?"

regards
sarva
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)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900