What is the purpose of the “get” and “set” properties in C#

前端 未结 7 1581
鱼传尺愫
鱼传尺愫 2020-12-30 12:35

I saw some get set method to set values. Can anyone tell me the purpose of this?

public string HTTP_USER_NAME
{
      get 
      {
            return UserNam         


        
7条回答
  •  旧时难觅i
    2020-12-30 12:45

    Check these links,.. they gives clear explanation.

    http://www.dotnetperls.com/property

    http://code.anjanesh.net/2008/02/property-getters-setters.html

    if UserName and UserPwd are class variables, better to use like this

    _userName 
    _userPwd
    

提交回复
热议问题