473,409 Members | 2,057 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,409 software developers and data experts.

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 992
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
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
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
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
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
2
by: Oenone | last post by:
In our applications, we use the special value of DateTime.MinValue to represent "null dates" throughout all our code. We recently ran into an issue where we wanted an optional date parameter for a...
5
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
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
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
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....
1
by: humsafar | last post by:
uploadeddate; startdate; date enddate;
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?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
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...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...

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.