Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8094221
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T20:43:59+00:00 2026-06-05T20:43:59+00:00

Possible Duplicate: Properties vs Methods I’m a beginner C# programmer and recently discovered how

  • 0

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.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-05T20:44:00+00:00Added an answer on June 5, 2026 at 8:44 pm

    If you just want to get and set a value then a property is best.

    public DateTime TheCurrentTime {get; set;}
    

    If you need to pass parameters in order to modify or return something then a method is best.

    public DateTime HowManyDaysUntilMyBirthday(Datetime MyBirthday) 
    {
        return (MyBirthday - DateTime.Now());
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Possible Duplicate: Properties vs Methods For many situations it is obvious whether something should
Possible Duplicate: C# - When to use properties instead of functions I am trying
Possible Duplicate: Properties vs Methods Is there any rule or general best practice as
Possible Duplicate: Atomic vs nonatomic properties I am getting issues (errors) if I use
Possible Duplicate: With ARC why use @properties anymore? NB: I actually don't think we
Possible Duplicate: How to use UTF-8 in resource properties with ResourceBundle I want to
Possible Duplicate: Enumerating through an object's properties (string) in C# Can I use reflection
Possible Duplicate: Should I Use self Keyword (Properties) In The Implementation? Say I have
Possible Duplicate: Properties vs Methods In method you can type some code and in
Possible Duplicate: When should I use static methods in a class and what are

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.