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 23: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 431
1 Afzaal Ahmad Zeeshan 184
2 /\jmot 176
3 Sergey Alexandrovich Kryukov 175
4 Marcin Kozub 175
0 OriginalGriff 8,344
1 Sergey Alexandrovich Kryukov 7,407
2 DamithSL 5,634
3 Maciej Los 5,024
4 Manas Bhardwaj 4,986


Advertise | Privacy | Mobile
Web03 | 2.8.1411023.1 | Last Updated 7 Nov 2012
Copyright © CodeProject, 1999-2014
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