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 8143077
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T12:59:57+00:00 2026-06-06T12:59:57+00:00

In the .Net framework DateTime structure, the Year is defined as an int (which

  • 0

In the .Net framework DateTime structure, the Year is defined as an int (which is really A System.Int32). However, the MSDN documentation says that the value will always be between 1 and 9999. Thus, a ushort (System.UInt16) is more than adequate to store the value and takes up half the space. So why is it an int and not a ushort?

There is an implicit conversion from ushort to int so there is no casting that needs to be done to do integer arithmetic on the Year.

I realize this is a micro-optimization issue and thus not very important. I am just curious.

  • 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-06T12:59:59+00:00Added an answer on June 6, 2026 at 12:59 pm

    Thus, a ushort (System.UInt16) is more than adequate to store the value and takes up half the space.

    Where do you think that “space” is being wasted? DateTime doesn’t store each component in a separate field anyway. If you’re storing the year somewhere, feel free to cast it to a ushort – and cast Month to a byte, etc.

    Note that ushort isn’t CLS-compliant, which is probably the reason for it. There are a lot of properties which would make sense to be unsigned, such as string.Length etc… but the framework tries to be CLS-compliant where it can.

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

Sidebar

Related Questions

Is there a static value defined in the .net framework library similar to DateTime.MinValue
The .net framework 4 is apparently going to include a BigInteger class. However, I
The .NET Framework allocates less memory for a Int32 than for a Int64 in
i am trying to understand how DateTime.ToString(Date pattern) work in .net framework, C#. I
I am very curious about this thing Int32 int addmonths_int = 10; DateTime.Now.AddMonths(addmonths_int); Int16
The namespace I'm looking at is System.Windows.Forms.DataVisualization.Charting in .NET Framework 3.5. I've constructed a
I have read a few articles about .Net Entity Framework that really didn't make
.NET framework 3.5 introduces Action and Func<> predefined delegate types that are very handy.
The .NET framework ships with 6 different hashing algorithms: MD5: 16 bytes (Time to
Microsoft .NET Framework Client Profile Offline Installer - 255.6 MB. Shouldn't it be 27MB

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.