Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. How do I defined property in C#?

How do I defined property in C#?

Scheduled Pinned Locked Moved C#
questioncsharptutorial
5 Posts 5 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • B Offline
    B Offline
    baisak
    wrote on last edited by
    #1

    I want to know how to define property?

    J P N 3 Replies Last reply
    0
    • B baisak

      I want to know how to define property?

      J Offline
      J Offline
      JF2015
      wrote on last edited by
      #2

      Hi, see here for the MSDN documentation: http://msdn.microsoft.com/en-us/library/x9fsa0sw%28VS.80%29.aspx[^]

      1 Reply Last reply
      0
      • B baisak

        I want to know how to define property?

        P Offline
        P Offline
        Pravin Patil Mumbai
        wrote on last edited by
        #3

        Do Refer : 1. http://www.c-sharpcorner.com/UploadFile/rajeshvs/PropertiesInCS11122005001040AM/PropertiesInCS.aspx[^] 2. http://www.csharp-station.com/Tutorials/Lesson10.aspx[^] Hope this helps. All the best.

        1 Reply Last reply
        0
        • B baisak

          I want to know how to define property?

          N Offline
          N Offline
          Nitheesh George
          wrote on last edited by
          #4

          Hi, To add a property say Name do the following in your class. private string _name; public string Name { get{ return _name;} set {_name = value;} } hope this helps. Nitheesh George http://www.simpletools.co.in

          F 1 Reply Last reply
          0
          • N Nitheesh George

            Hi, To add a property say Name do the following in your class. private string _name; public string Name { get{ return _name;} set {_name = value;} } hope this helps. Nitheesh George http://www.simpletools.co.in

            F Offline
            F Offline
            fjdiewornncalwe
            wrote on last edited by
            #5

            It does, but just as a note. In an instance like this it is cleaner to use the auto-property. public string name { get; set; } with no private member defined. (Your answer is still correct, of course)

            I wasn't, now I am, then I won't be anymore.

            1 Reply Last reply
            0
            Reply
            • Reply as topic
            Log in to reply
            • Oldest to Newest
            • Newest to Oldest
            • Most Votes


            • Login

            • Don't have an account? Register

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • World
            • Users
            • Groups