TheCommunicator
asked on
What is difference between proerty and global variable?
Sometimes it makes me wonder that why do we have to use properties all the times when all they are used for is to hold some values while execution is going on?
Can't we use global variables for that? I mean I see that when we serialize and de-serialize the objects, we can take advantage of proprties being there but other than that what exact benefits that properties give as as opposed to the public variables?
Can't we use global variables for that? I mean I see that when we serialize and de-serialize the objects, we can take advantage of proprties being there but other than that what exact benefits that properties give as as opposed to the public variables?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
global is static and should be not a part of class object. proerty can be a part of class object.
See following URL:
http://dotnetperls.com/global-variables-aspnet
Let me know for more information
See following URL:
http://dotnetperls.com/global-variables-aspnet
Let me know for more information
ASKER
Thank you so much guys. I am new to C# but the question here is why did C# people decide to introudce the whole new concept of Static properties rather than traditional C++ style properties?
I understand the point that mac-will raised that it does the validation but other than that GET and Set methods are nothing but methods to retrieve value of that property whcih can be easily done with Public variables, right?
I understand the point that mac-will raised that it does the validation but other than that GET and Set methods are nothing but methods to retrieve value of that property whcih can be easily done with Public variables, right?
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thank you so much guys. each author's comments was equally helpful and I am really thankful to you guys, :)
I assumed you meant public class fields. Was that correct?