如何确定一个对象是否是 VB.NET 中的 DateTime

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/3998685/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-09 15:05:33  来源:igfitidea点击:

How to determine if an object is a DateTime in VB.NET

vb.netc#-to-vb.net

提问by DanP

The following works fine in c# (assuming valueis an object):

以下在 c# 中工作正常(假设value是一个object):

if (value is DateTime)

What is the equivalent check for VB.NET?

VB.NET 的等效检查是什么?

回答by tnyfst

The VB.Net equivalent is

VB.Net 等价物是

If TypeOf(value) Is DateTime Then

回答by Brad

C#

C#

if (value.GetType() is typeof(DateTime)) {}

VB.NET (so the converters tell me)

VB.NET(所以转换器告诉我)

If value.[GetType]() Is GetType(DateTime) Then
    '...
End If

回答by Klaus Byskov Pedersen

If TypeOf value Is DateTime Then