473,507 Members | 13,917 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Difference? myDate.Equals(Date.MinValue) -or- myDate = Date.MinValue

Hello,
what is the difference and what is better (performance etc) ?

a) If myDate.Equals(Date.MinValue)
b) If myDate = Date.MinValue

Thanks,
Andreas
Nov 17 '05 #1
3 1514
Don't know about VB but in C# the operator calls the function. Depending on
the compiler the function might be faster (but most likely it will be the
same as the compiler will do the substitution, much like inline functions in
C++).

Jerry

"Andreas Klemt" <ak******@hotmail.com> wrote in message
news:%2****************@TK2MSFTNGP09.phx.gbl...
Hello,
what is the difference and what is better (performance etc) ?

a) If myDate.Equals(Date.MinValue)
b) If myDate = Date.MinValue

Thanks,
Andreas

Nov 17 '05 #2
Hello,

results are:

a) If myDate.Equals(Date.MinValue)
0,007439

b) If myDate = Date.MinValue
0,002253

Regards,
Andreas
"MS News (MS ILM)" <sq**********@hotmail.com> schrieb im Newsbeitrag
news:eD**************@tk2msftngp13.phx.gbl...
Time stamp it
Run a loop 1000000000 times and see which one is better
Please let us know
"Andreas Klemt" <ak******@hotmail.com> wrote in message
news:%2****************@TK2MSFTNGP09.phx.gbl...
Hello,
what is the difference and what is better (performance etc) ?

a) If myDate.Equals(Date.MinValue)
b) If myDate = Date.MinValue

Thanks,
Andreas


Nov 17 '05 #3
Take a look in IL and you will see that CLR use Boxing just for Equals.
Equals should be slower.

//000004: Dim myDate As Date
//000005: If myDate.Equals(Date.MinValue) Then
IL_0001: ldloca.s myDate
IL_0003: ldsfld valuetype [mscorlib]System.DateTime
[mscorlib]System.DateTime::MinValue
IL_0008: box [mscorlib]System.DateTime
IL_000d: call instance bool
[mscorlib]System.DateTime::Equals(object)
IL_0012: brfalse.s IL_0014
//000006:
//000007: End If
IL_0014: nop
//000008: If myDate = Date.MinValue Then
IL_0015: ldloc.0
IL_0016: ldsfld valuetype [mscorlib]System.DateTime
[mscorlib]System.DateTime::MinValue
IL_001b: call int32
[mscorlib]System.DateTime::Compare(valuetype [mscorlib]System.DateTime,

valuetype [mscorlib]System.DateTime)
IL_0020: ldc.i4.0
IL_0021: bne.un.s IL_0023
//000009:
//000010: End If

Natty Gur, CTO
Dao2Com Ltd.
34th Elkalay st. Raanana
Israel , 43000
Phone Numbers:
Office: +972-(0)9-7740261
Fax: +972-(0)9-7740261
Mobile: +972-(0)58-888377
*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 17 '05 #4

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

Similar topics

5
581
by: Andreas Klemt | last post by:
Hello, I have this Dim myDate As Date ... ... How can I check if this date is empty (value #12.00.00 AM# is in there) ? Thanks,
3
999
by: Andreas Klemt | last post by:
Hello, what is the difference and what is better (performance etc) ? a) If myDate.Equals(Date.MinValue) b) If myDate = Date.MinValue Thanks, Andreas
8
3247
by: JIM.H. | last post by:
Hello, I am calling a stored procedure to update my table. If one of the date on the screen left empty, I need to send date as null. Since MyDate=”” gives error in asp.net, how should I do...
1
1584
by: RK | last post by:
What is the difference in performance if using XmlDocument or XmlElement as parameter in C# class method. thanks in advance. --RK
5
1316
MitchR
by: MitchR | last post by:
Hello to All; I have inherited a database and need to have the database post a date in a comments column which I can do. Problem is every time I execute the event procedure it replaces the old date...
0
1018
by: =?Utf-8?B?cm9kY2hhcg==?= | last post by:
hey all, is there any difference between right clicking on my web page and saying view in browser or doing a Debug/Start Without Debug ? As far as stuff like cache, Needing to use Rebuild Page for...
3
1129
madhoriya22
by: madhoriya22 | last post by:
HI, I am using this query to get the count from table select count(*) from defect_detail where status = 'RESOLVED' OR 'CLOSED' OR 'VERIFIED' It is retruning count 15. And when I am using...
18
8872
by: saykenari | last post by:
Hello Friends I have a problem date format written as DD/MM/YYYY. Date already save into a file as binary. I don't know which technique should be used. Sample date as following a....
0
7221
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
7313
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
7372
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...
1
7029
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
7481
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
5619
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development projectplanning, coding, testing,...
0
3190
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
1537
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
758
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.