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