locked
Auto implemented properties RRS feed

  • Question

  • Hi,

    What are auto implemented properties?

    Sunday, June 24, 2012 2:00 PM

Answers

All replies

  • Hello BGQQ,

    Hi,

    What are auto implemented properties?

    follow this link of Msdn Library http://msdn.microsoft.com/en-us/library/dd293589.aspx

    Regards.


    • Marked as answer by BGQQ Sunday, June 24, 2012 6:03 PM
    Sunday, June 24, 2012 2:07 PM
  • OK.....

    Thanks ....

    but if we do not write code for Get and Set procedures, so what is the difference between auto implemented properties and fields?

    Sunday, June 24, 2012 2:24 PM
  • Hello BGQQ,

    OK.....

    Thanks ....

    but if we do not write code for Get and Set procedures, so what is the difference between auto implemented properties and fields?

    automatically deploying the properties as you saw in the link and the compiler to create a private field and behind the scenes to implement everything that you would normally write if you do not do automatic deployment, and visible variables declared at the class level are called fields .

    Reagards.


    Sunday, June 24, 2012 3:10 PM
  • Thanks again.

    I really appreciate your replies.

    My point is what is the practical difference between:

                         Public CT as Integer         'Field

    and

                         Public Property CT as Integer              'Auto implemented Property

    Both could be used in the same way outside the class and they have same functionality?

    Let MC be the name of the instance of the class

    then in both cases(Field and auto implemented property) we may write:

                           MC.CT = 5

    or

                           Dim n as Integer = MC.CT

    These lines will have same effect whether CT is declared as a field or as auto implemented property?

    Sunday, June 24, 2012 5:23 PM
  • Hello BGQQ,

    Thanks again.

    I really appreciate your replies.

    My point is what is the practical difference between:

                         Public CT as Integer         'Field

    and

                         Public Property CT as Integer              'Auto implemented Property

    Both could be used in the same way outside the class and they have same functionality?

    Let MC be the name of the instance of the class

    then in both cases(Field and auto implemented property) we may write:

                           MC.CT = 5

    or

                           Dim n as Integer = MC.CT

    These lines will have same effect whether CT is declared as a field or as auto implemented property?

    None at the functional level, for the purpose of application fields should be kept private, never public, should not be visible outside the class, but the properties are useful when you want to exchange information between classes, an example and when you declare an instance of a Form , inside the state of the property, and pass the values ​​from the caller to the called form.

    Regards.


    Sunday, June 24, 2012 5:32 PM
  • I also (still) don't see the purpose.

    Maybe one usage can be for implementing properties. For example, if you implement an interface with a property, the auto-implemented property can implement the property of the interface. (in which "implemented" has two different meanings here) So you need a property. A field could not implement the property.


    Armin

    Sunday, June 24, 2012 5:48 PM
  • Thank you very much for your replies.
    Sunday, June 24, 2012 6:06 PM
  • Hello BGQQ,

    Thank you very much for your replies.

    You're Welcome.

    Best Regards.


    Sunday, June 24, 2012 6:32 PM