user1159518
user1159518

Reputation: 13

DateTime gets changed to Date in service reference proxy

When I add a service reference to my VB.Net project all of the properties of type DateTime get changed to type Date. The project is ASP.Net using framework 4.0. The web service being referenced is C# framework 4.0.

How can I keep this from happening?

Upvotes: 1

Views: 288

Answers (1)

Jon Skeet
Jon Skeet

Reputation: 1503459

As far as I'm aware, Date in VB is just an alias for the DateTime CLR type. For example, this code:

Public Class Foo

  Public Shared Sub Main(args As String())
      Dim x As Date = New Date
  End Sub

End Class

compiles to the equivalent of:

public class Foo
{
    public static void Main(string[] args)
    {
        DateTime x = new DateTime();
    }
}

So the types aren't really being changed - they're just being shown as Date. It's much like the difference between Int32 and int in C#, I believe. (There may be some other differences such as extra methods provided via Date, but the values are of the same type.)

Upvotes: 1

Related Questions