| | |

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

 Forgot password?
 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
View: 2356|Reply: 0

Differences

[Copy link]

0

Threads

0

Friends

473

Money

Administrator

Rank: 9Rank: 9Rank: 9

Medal No.2

Post time: 9-3-2009 05:41 PM
|Show all posts
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

Use magic Report

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

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

22-8-2019 01:20 PM GMT+8 , Processed in 0.109268 sec., 22 queries .

Powered by Discuz! X2.5

Release 20121101, © 2001-2019 Comsenz Inc.

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

To Top