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

Ask a Question related to ASP.NET General, Design and Development.

  1. #1

    Default 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


    Andreas Klemt Guest

  2. Similar Questions and Discussions

    1. JSObject returns wrong date. How can Iextract correct date from digital signature?
      I'm trying to extract name and date from digital signatures by using JSObject in Excel VBA, but JSObject returns wrong date. Year, month, hour and...
    2. #39245 [NEW]: date function generate wrong date with 1162083600 timestamp
      From: lohner at aldea dot hu Operating system: Linux PHP version: 5.1.6 PHP Bug Type: Date/time related Bug description: ...
    3. how to display empty when the date is MinValue in datagrid
      In the Datagrid clolumns there is one is DateTime Type. It always shows DateTime.MinValue. How can It show emptty string instead? I Know I can do...
    4. How do I manipulate a date variable to a specific date array?
      Hi, I use the getdate() function to return today's date in an array. I do this as I need to separate the day/month/year as to display them in a...
  3. #2

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

    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" <[email protected]> wrote in message
    news:%[email protected]..
    > Hello,
    > what is the difference and what is better (performance etc) ?
    >
    > a) If myDate.Equals(Date.MinValue)
    > b) If myDate = Date.MinValue
    >
    > Thanks,
    > Andreas
    >
    >

    Jerry III Guest

  4. #3

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

    Hello,

    results are:

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

    b) If myDate = Date.MinValue
    0,002253

    Regards,
    Andreas


    "MS News (MS ILM)" <[email protected]> schrieb im Newsbeitrag
    news:[email protected]..
    > Time stamp it
    > Run a loop 1000000000 times and see which one is better
    > Please let us know
    >
    >
    > "Andreas Klemt" <[email protected]> wrote in message
    > news:%[email protected]..
    > > Hello,
    > > what is the difference and what is better (performance etc) ?
    > >
    > > a) If myDate.Equals(Date.MinValue)
    > > b) If myDate = Date.MinValue
    > >
    > > Thanks,
    > > Andreas
    > >
    > >
    >
    >

    Andreas Klemt Guest

  5. #4

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

    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 [url]http://www.developersdex.com[/url] ***
    Don't just participate in USENET...get rewarded for it!
    Natty Gur Guest

  6. #5

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

    Hi,

    run ILdasm.exe, open your assembly and look for your method. befor open
    it enable show source lines from view menu.


    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 [url]http://www.developersdex.com[/url] ***
    Don't just participate in USENET...get rewarded for it!
    Natty Gur Guest

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139