DanP
DanP

Reputation: 6478

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

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

if (value is DateTime)

What is the equivalent check for VB.NET?

Upvotes: 9

Views: 24150

Answers (3)

Brad
Brad

Reputation: 15577

C#

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

VB.NET (so the converters tell me)

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

Upvotes: 10

Klaus Byskov Pedersen
Klaus Byskov Pedersen

Reputation: 120937

If TypeOf value Is DateTime Then

Upvotes: 2

tnyfst
tnyfst

Reputation: 1601

The VB.Net equivalent is

If TypeOf(value) Is DateTime Then

Upvotes: 18

Related Questions