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.
"Peter Bromberg [C# MVP]" wrote:
Ctype doesn't throw an exception, DirectCast, while more efficient, assumes
that you know exactly what the type is. Additional behavior would be
controlled by having Option Strict and Option Explicit both set to "true" -
which you should always do with VB.NET.
-- Peter
Recursion: see Recursion
site: http://www.eggheadcafe.com
unBlog: http://petesbloggerama.blogspot.com
BlogMetaFinder: http://www.blogmetafinder.com
"Mike" wrote:
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