473,411 Members | 1,975 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,411 software developers and data experts.

Why is System.DateTime a structure?

I am curious why did Microsoft write System.DateTime as a structure instead
of a class?

Maybe for backward compatibilty with any existing old code?

FYI, one of the differences between structure and class is we can set the
structure to Nothing.


Nov 20 '05 #1
3 1065
Sorry it should be:
one of the differences between structure and class is we can NOT set the
structure to Nothing.

"Pram" <pr**@nospam.com> wrote in message
news:uw**************@TK2MSFTNGP09.phx.gbl...
I am curious why did Microsoft write System.DateTime as a structure instead of a class?

Maybe for backward compatibilty with any existing old code?

FYI, one of the differences between structure and class is we can set the
structure to Nothing.

Nov 20 '05 #2
* "Pram" <pr**@nospam.com> scripsit:
I am curious why did Microsoft write System.DateTime as a structure instead
of a class?

Maybe for backward compatibilty with any existing old code?

FYI, one of the differences between structure and class is we can set the
structure to Nothing.


Why is a 'Point' a structure? Why a 'Rectangle'? I think that most of
the structures in the .NET framework have two things in common: They are
very simple, use mostly simple datatypes (value types) and when working
with them often copies of the objects are created.

--
Herfried K. Wagner
MVP · VB Classic, VB.NET
<http://www.mvps.org/dotnet>

Improve your quoting style:
<http://learn.to/quote>
<http://www.plig.net/nnq/nquote.html>
Nov 20 '05 #3
Pram,
I believe DateTime is a structure, as it meets all the criteria to use when
deciding to make a type a Structure as set forth by the .NET Design
Guidelines for Class Library Developers, in that it:

- Acts like a primitive type
- It has an instance size of under 16 bytes
- It is immutable
- It has value semantics.

Which is 4 for 4!

http://msdn.microsoft.com/library/de...guidelines.asp

The one item that is not listed, but is implied by the above list is as a
Structure it is significantly easier to work with as opposed to being a
class!

Hope this helps
Jay

"Pram" <pr**@nospam.com> wrote in message
news:uw**************@TK2MSFTNGP09.phx.gbl...
I am curious why did Microsoft write System.DateTime as a structure instead of a class?

Maybe for backward compatibilty with any existing old code?

FYI, one of the differences between structure and class is we can set the
structure to Nothing.

Nov 20 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Pram | last post by:
I am curious why did Microsoft write System.DateTime as a structure instead of a class? Maybe for backward compatibilty with any existing old code? FYI, one of the differences between...
2
by: Robert | last post by:
I have no problem storing dates + times in a System.DateTime object. In addition, it's easy to output a Time as a string from an existing Date/Time. But I'm having trouble storing a time only. ...
14
by: Jon Davis | last post by:
I have put my users through so much crap with this bug it is an absolute shame. I have a product that reads/writes RSS 2.0 documents, among other things. The RSS 2.0 spec mandates an en-US style...
3
by: Ivan A. | last post by:
Hi! Why I can't serialize TimeSpan structure with XmlSerializer? This is what I do: using System; using System.IO; using System.Xml; using System.Xml.Serialization;
5
by: A.M | last post by:
Hi, I know we can assigne year, month and day to a DateTime value by the constructor like Dim dt As DateTime = New DateTime(2003,8,1) How can i assign value by year, month and day? I am...
2
by: Fredrik Melin | last post by:
Is there any way to extend or write a own "System.Decimal"? In the doc its declared as <Serializable> Public Structure Decimal Implements IFormattable, IComparable, IConvertibleBut how do you...
13
by: Alan M Dunsmuir | last post by:
I need to specify a new data type, almost entirely a 'clone' of the existing DateTime type, with the following specific difference, and all the consequent differences in properties and methods...
11
by: frizzle | last post by:
Hi groupies I'm building a news site, to wich a user can add new items into a mySQL db. It's still in testfase, but it's so extremely slow, i want to figure out what i'm doing wrong, or what to...
7
by: =?Utf-8?B?Q29ubnVsbA==?= | last post by:
Can anybody assist me on the code to set the System's ShortDate format to yyyy/MM/dd at runtime?
5
by: indika | last post by:
Hi, I'm a newbie to python but have some experience in programming. I came across this requirement of using datetime.date objects associated with some another object. eg. a dictionary containing...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.