Class structure - property

Similarities and Differences between local variables and properties

Same point:

  1. Format-defined variables: variable name = data type variable value
  2. After the first use statement
  3. Variable has its corresponding scope

difference:

  1. Different positions in the class declaration of
    attributes: a pair of directly defined within {} class
    local variables: variables in the process, process parameters within the code block, the constructor parameter, the internal statement constructor

  2. Permissions on different modifier
    attributes: You can declare properties when specifying their rights, usage rights modifier
    local variables: not use Permissions modifier

  3. The default initialization value distinct
    properties: property class, according to their type, have default initialization values (default initialization value like array)
    local variables: no default initialization value

Published 165 original articles · won praise 8 · views 9000

Guess you like

Origin blog.csdn.net/wait_13/article/details/104279402