Mamakcafe.com Malaysia Forum | Technology  | Property | Web Hosting & Domain | Online Marketing forum

 !forgotpw!
 Register with Mamakcafe
!search!
BigDomain.my  Free Website Builder dear user, mamakcafe is a free service, please do not be provocative and offensive to others user. if user are found to be offensive, it will be removed from the system and permenently banned
!show!: 2219|!reply!: 0

Differences

[!share_url_copy!]

0

!threads!

0

!friends!

473

!credits!

Administrator

Rank: 9Rank: 9Rank: 9

Medal No.2

!poston!: 9-3-2009 05:41 PM
|!thread_show_all!
Between property and field (Global Variable in class)

syntax of field:
private class form1()
{
    public int m_nSharedValue;
}

private class form2()
{
   private void Get value()
   {
      form1 instance = new form1();
      instance.m_nSharedValue = 1000;
   }
}

syntax of property:
private class form1()
{
  private int m_nSharedValue;

  public int SharedValue
 {
    get{ return m_nSharedValue;}
    set{ m_nSharedValue = value;}
  }
}

private class form2()
{
     form1 instance = new form1();
      instance.SharedValue = 1000;
}

Field  Property
 can get and set value directly
Use get and set method to do it
 -  can set to fire event if value changed.
 -  Inside set method, we can add extra code for process that value we want to execute.
 -  Inside set method, we can check the value first before assign to actual field

Con of Property:
1. waste more cycle time.
[ Last edited by owner at 9-3-2009 05:44 PM ]
!reply!

!thread_magic! !report!

RM5.99 Malaysia Domain names with FREE Hosting @ bigdomain.my

Mobile version| Archiver| Mamakcafe.com a Malaysia Forum | Technology | Property | Web Hosting & Domain | Online Marketing forum , hosted on Bigdomain.my

!time_now! , Processed in 0.156017 sec., 22 queries .

Powered by Discuz! X2.5

Release 20121101, © 2001-2019 Comsenz Inc.

MultiLingual version, Rev. 85, © 2009-2019 codersclub.org

!scrolltop!