Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C#4.0
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; }
 

regards
sarva
Posted 6-Nov-12 22:21pm
Sarrrva3.4K

1 solution

Rate this: bad
good
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.
 
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.
  Permalink  
Comments
Sarrrva at 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 at 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
0 OriginalGriff 454
1 Maciej Los 404
2 CPallini 185
3 Sergey Alexandrovich Kryukov 182
4 Richard MacCutchan 120
0 OriginalGriff 5,634
1 Sergey Alexandrovich Kryukov 4,763
2 Peter Leow 2,954
3 Maciej Los 2,614
4 DamithSL 2,465


Advertise | Privacy | Mobile
Web01 | 2.8.140718.1 | Last Updated 7 Nov 2012
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid