Possible Duplicate:
Properties vs Methods
I'm a beginner C# programmer and recently discovered how to use properties to expose members. However I'm confused on when to use a property as apposed to a method when returning something.
Should I do this:
public Vector2 Center {
get {
Vector2 screenDem = new Vector2(game.GraphicsDevice.Viewport.Width,
game.GraphicsDevice.Viewport.Height);
return new Vector2(screenDem.X / 2, screenDem.Y / 2);
}
}
or should I do something like this:
public Vector2 GetScreenCenter() {
Vector2 screenDem = new Vector2(game.GraphicsDevice.Viewport.Width,
game.GraphicsDevice.Viewport.Height);
return new Vector2(screenDem.X / 2, screenDem.Y / 2);
}
When should I use which and why?
Maybe I'm just thinking about this too hard and it doesn't matter, I don't know.
Thanks.