Why do ASP.NET Settings Properties use CTYPE instead of DirectCast


G

Guest

If Visual Studio knows the type, why does the system-generated property use
CType instead of DirectCast? DirectCast is more efficient right?

For example - Here's what we have for a setting named
'StandardWebsiteUserRoleID'...
Public ReadOnly Property StandardWebsiteUserRoleID() As Integer
Get
Return CType(Me("StandardWebsiteUserRoleID"),Integer)
End Get
End Property

Thanks
 
Ad

Advertisements

M

Michael D. Ober

I think CType is a VB wrapper for DirectCast, and as such, it probably has
some additional checks that DirectCast doesn't have.

Mike Ober.
 
Ad

Advertisements

G

Guest

Your statement is exactly correct. So then why for Settings, when we do know
exactly what the type is, doesn't Visual Studio use DirectCast instead of
CTYPE?

It just seems logical to me that since we're sure of the type, Visual Studio
chooses to use CTYPE.

In the end it doesn't really matter, but it does make me curious.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top