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

  • SEARCH
  • Home
  • 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 8008763
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T18:14:16+00:00 2026-06-04T18:14:16+00:00

I have been looking through the DateTime structure and I am slightly confused. My

  • 0

I have been looking through the DateTime structure and I am slightly confused.

My understanding with structs is that you cannot assign ‘default values’ of fields. If the default constructor of a struct is used (which is not something that you can control), then any fields will be initialized using the default values of their value type.

This is all good and well, but why then is the default value of the ‘Days’ property of a DateTime equal to 1? How do they pull that off?

William

  • 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-04T18:14:17+00:00Added an answer on June 4, 2026 at 6:14 pm

    You need to understand the difference between fields and properties.

    The fields are all initialized to 0, but the properties can do what they like with those fields. Sample:

    public struct Foo
    {
        private readonly int value;
    
        public Foo(int value)
        {
            this.value = value;
        }
    
        public int ValuePlusOne { get { return value + 1; } }
    }
    
    ...
    
    Foo foo = new Foo(); // Look ma, no value! (Defaults to 0)
    int x = foo.ValuePlusOne; // x is now 1
    

    Now obviously DateTime is a smidge more complicated than this, but it gives the right idea 🙂 Imagine what “A DateTime with the field explicitly set to 0″ would mean… the “default” DateTime just means exactly the same thing.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have been looking through Google and SO for something that could help me
I have been looking thoroughly through the Web and I cannot seem to find
I have been looking through StackOverflow a lot and found SOME solutions but they
I have been looking through code for the last 3 days, and the original
I have been looking through some code on an open source project recently and
I have been working with some bash scripting lately and been looking through the
I am interested in using a DataObject and have been looking through the documentation.
OK, I have been looking for weeks now. I have looked through Eclipse and
I've been looking through other questions/answers, but couldn't find anything that was helping. I
I have been looking through some MFC code and i came across this expression.

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.