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

  • Thread starter Thread starter Guest
  • Start date Start date
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
 
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.
 
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.
 
Back
Top