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. Get/Set

Get/Set

Scheduled Pinned Locked Moved C#
helpquestion
3 Posts 2 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.
  • E Offline
    E Offline
    Expert Coming
    wrote on last edited by
    #1

    How does this work exactly? I am trying to use a mouse cursor postion get and set function, but I can't remember how it worked exactly. Thanks for all the help.

    D 1 Reply Last reply
    0
    • E Expert Coming

      How does this work exactly? I am trying to use a mouse cursor postion get and set function, but I can't remember how it worked exactly. Thanks for all the help.

      D Offline
      D Offline
      Daniel Monzert
      wrote on last edited by
      #2

      Accessors look like this: public Point MouseCursorPosition { get { return m_MouseCursorPosition; } set { m_MouseCursorPosition = value; } } When getting a value from "MouseCursorPosition", it returns the value of the private member m_MouseCursorPosition. With accessors you can make private members to be read-only if needed. Simply leave the set accessor and only implement the get accessor. As an option you can add more code to the bodies of get/set if needed. For example.. public Bitmap Picture { get { return m_Picture; } set { m_Picture = value; RedrawBitmap(); } } .. you draw the new picture that is set. Accessors are cute :)

      E 1 Reply Last reply
      0
      • D Daniel Monzert

        Accessors look like this: public Point MouseCursorPosition { get { return m_MouseCursorPosition; } set { m_MouseCursorPosition = value; } } When getting a value from "MouseCursorPosition", it returns the value of the private member m_MouseCursorPosition. With accessors you can make private members to be read-only if needed. Simply leave the set accessor and only implement the get accessor. As an option you can add more code to the bodies of get/set if needed. For example.. public Bitmap Picture { get { return m_Picture; } set { m_Picture = value; RedrawBitmap(); } } .. you draw the new picture that is set. Accessors are cute :)

        E Offline
        E Offline
        Expert Coming
        wrote on last edited by
        #3

        Ok, I feel alot closer, but I am now getting this error. m_MouseCursorPosition does not exist in the namespace. I also need to know how I store that point to use in another function.

        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