Microsoft.VisualBasic.Now vs. System.DateTime.Now

Is there a difference between using Microsoft.VisualBasic.DateAndTime.Now compared to System.DateTime.Now?

I seem to remember reading something that the MS.VB namespace was intended to be used only in an obsolete way and was much slower than using the native .net classes.

+5
source share
5 answers

There are times when using the VB namespace may be slower (due to added functionality and / or flexibility, and not because MS wants the VB to be slower).

But in the case of DateAndTime.Now, this is not so. This is just a wrapper around calling DateTime.Now.

, JIT-, ( Release).

: IL DateAndTime.Now:

.method public specialname static valuetype [mscorlib]System.DateTime get_Now() cil managed
{
    .maxstack 1
    .locals init (
        [0] valuetype [mscorlib]System.DateTime time)
    L_0000: call valuetype [mscorlib]System.DateTime [mscorlib]System.DateTime::get_Now()
    L_0005: ret 
}

, :

Return DateTime.Now
+9

, ( , ); VB # , VisualBasic, . , .

+2

. Now, DateTime.Now. , Year(). GetYear(), , DateTime.Now.Year. , , , , . VB6 , VB6.

+2

VB6 , ; .net DateTime.

+1

VB , VB 6 .

Which looks like a legacy, but not quite.

0
source

All Articles