+ Reply to Thread
Results 1 to 2 of 2

Thread: The value Keyword confuses me

  1. #1

    The value Keyword confuses me

    Hi , i had that code before :
    Code:
    public DicSerializer<String, Point> jointDic
        {
            get { return _jointDic; }
            set { _jointDic = jointDic; }
        }
    I use that code in order to serialize/deserialize an object with a dictionary , but however i had an issue with the above code and i modified it to the below code and it worked :
    Code:
    public DicSerializer<String, Point> jointDic
        {
            get { return _jointDic; }
            set { _jointDic = value; } // changed that and added value keyword
        }
    Now i am confused , when should i use the "value" ?
    Last edited by basemhosam; 01-23-2012 at 07:24 PM.

  2. #2
    Junior Member
    Join Date
    Jan 2012
    Posts
    40
    The keyword value represents the value which is being passed to the property. You should always use it within the setter property .
    In the case you used jointDictionary you were binding to the property getter. This makes
    Code:
    set { _jointDic = jointDic; }
    Compiles to
    Code:
    set { _jointDic = this.jointDic; }
    Which since this accesses the property getter it really becomes
    Code:
    set { _jointDic = _jointDicy; }

+ Reply to Thread

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts