Is there any difference between using the Microsoft.VisualBasic.DateAndTime.Now compared to the System.DateTime.Now?
I seem to remember reading something that said the MS.VB namespace was for legacy use only, and was much slower than using the native .net classes.
There might be some cases, where using the VB namespace might be slower (because of the added functionality and/or flexibility, not because MS wants VB to be slower).
But in the case of DateAndTime.Now, this is not the case. This is simply a wrapper around a call to DateTime.Now.
I suspect the call to be inlined by the JIT-compiler, so it will not make your code any slower (when compile for Release).
Prove: This is the IL from 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
}
this is exactly the same as:
Return DateTime.Now
I don't know if it's slower (and doubt it's enough to matter); but I've done enough porting between VB and C# and back to avoid the VisualBasic namespace when a System equivalent is available. It's just one more thing to worry about.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With