TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Zygis
NA
14
13.8k
Properties {get;set;}
Aug 18 2011 6:42 AM
Hi,
I have some problems with {get; set;} thing, hope you could help.
So I have a class:
class Parts
{
public Vector2 partPos { get; set; }
public bool moving { get; set; }
/*public Parts()
{
}*/
//private Vector2 PartPos;
/*public Vector2 partPos
{
get
{
return PartPos;
}
set
{
PartPos = value;
}
}*/
//private bool Moving;
/*public bool moving
{
get
{
return Moving;
}
set
{
Moving = value;
}
}*/
}
Problem is that I can't modify only the X or only the Y coordinate of Vector2 partPos (I have to create a new Vector2 and then set it to partPos). Is there any way of doing that with get set properties? Because this part of code is not acceptable:
public float partPos.X {get; set;}
Also I have thought about adding this line of code:
public float partPosX { get { return partPos.X; } set { partPos.X = value; } }
, but it's also not acceptable because partPos is not a variable.
I think I don't get something here :/.
Thanks in advance for any help!
Reply
Answers (
1
)
Line break in c#
Unable to open the saved application