C# Tutorials and offshore development in India
    Tutorials   Resources   Forum   Communities   Interview   Jobs   Projects   Offshore Development    
Silverlight Tutorials | Mentor | Code Converter | Articles | Code Factory | Computer Jokes | Members | Peer Appraisal | IT Companies | Bookmarks | Revenue Sharing |


Prizes & Awards
My Profile



Active Members
TodayLast 7 Days more...

New Feature: Community Sites: Create your own .NET community website and start earning from Google AdSense ! It's Free !




diff between public property and public variable?


Posted Date: 01 Aug 2006      Total Responses: 1

Posted By: vivek rajendran       Member Level: Silver     Points: 2




diff between public property and public variable?




Responses

Author: Jyoti Sharma    01 Aug 2006Member Level: GoldRating:     Points: 2
The difference between a field and a property is that a field's value can be
set directly. A property has a get and set method for getting and setting
field data. There are several reasons why you might use a property instead
of a field. You may want to do additional processing, or fire an event, when
the value of a property changes. The property's set method can contain any
additional code you want to execute when you set the value. You may want to
check the value being assigned to a field prior to allowing the programmer
to set it. This can also be done in a property, but not in a field. In the
case of ViewState properties, you are exposing a ViewState member via a
property whose set and get methods access ViewState and check to see whether
the value is null or not, and can return a default value if it is null.
There are other reasons as well, such as external dependencies, which may
require a property rather than a field for some reason, etc.

Bottom line is, if you need any additional processing when setting or
getting a value, make it a property. Otherwise, you may be wasting cycles.



Author: Prem Kumar.O.M.    01 Aug 2006Member Level: GoldRating:     Points: 2
Hi
Public variables are technically called as fields.

If you have VS.NET Help, just go through this link

ms-help://MS.VSCC.v80/MS.MSDN.v80/MS.VisualStudio.v80.en/dv_csref/html/f7f67b05-0983-4cdb-96af-1855d24c967c.htm

else go thru the below links

http://discuss.fogcreek.com/dotnetquestions/default.asp?cmd=show&ixPost=5814

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vbcn7/html/vbconPropertyProceduresVsPublicVariables.asp


Regards
Prem


Post Reply
You must Sign In to post a response.
Next : urgent pls
Previous : how to handle the error in stored procedures?
Return to Discussion Forum
Post New Message
Category: .NET

Related Messages



dotNet Slackers   BizTalk Adaptors    Web Design

conference calls

Contact Us    Privacy Policy    Terms Of Use