For times like these, you can employ the System.Text.Encoding
class to convert to and from various encodings, including ASCII, UTF-7, UTF-8, and UTF-32.
Incidentally, the Unicode format used internally by the runtime is UTF-16.1
String Literals
When you declare a string in your code, the compiler creates a System.String object for you
that it then places into an internal table in the module called the intern pool. The idea is that
each time you declare a new string literal within your code, the compiler first checks to see if
you??™ve declared the same string elsewhere, and if you have, then the code simply references
the one already interned. Let??™s take a look at an example of ways to declare a string literal:
Imports System
Public Class EntryPoint
Shared Sub Main(ByVal args As String())
Dim lit1 As String = "c:\windows\system32"
Dim lit2 As String = "c:\windows\system32"
Dim lit3 As String = vbCrLf & "Jack and Jill" & vbCrLf & _
"Went up the hill . . ." & vbCrLf
Console.WriteLine(lit3)
Console.WriteLine("Object.RefEq(lit1, lit2): {0}", _
Object.ReferenceEquals(lit1, lit2))
If args.Length > 0 Then
Console.WriteLine("Parameter given: {0}", args(0))
Dim strNew As String = String.Intern(args(0))
Console.WriteLine("Object.RefEq(lit1, strNew): {0}", _
Object.
Pages:
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284