Reputation: 3
I have to convert a VB.NET String variable into a type of SqlChars (a built-in VB.NET type).
The code I am using is:
Dim sqlPolyStr As String
sqlPolyStr = "POLYGON((" & ptsStr & "))"
Dim sqlChrsPoly As New SqlChars(sqlPolyStr)
The code works fine, I just wondered if there is a name for the process of conversion between types that is taking place?
Upvotes: 0
Views: 82
Reputation: 1976
While I know what you're talking about, this isn't a great example because that's not quite converting the object, it is using a constructor and that constructor is doing stuff in the background.
A better example is dim a as integer = cType("12345", integer)
This process is known as typecasting and more details can be found here. My example is still poor because in vb.net you can still do dim a as integer = "12345"
but it's a start for you.
The example you gave uses the constructor. Whoever programmed "SqlChars" made a constructor that accepts type String
by making a sub such as
Public Sub New(ByVal str as string)
' DO something here with the string to make a SqlChars object
End Sub
Upvotes: 1