Prev | Current Page 273 | Next

Guy Fouch?©, Trey Nash

"Accelerated VB 2008"

ReferenceEquals(lit1, strNew))
End If
End Sub
End Class
Here??™s the output from the previous example:
Jack and Jill
Went up the hill . . .
CHAPTER 9 n WORKING WITH STRINGS 168
1. For more information regarding the Unicode standard, visit www.unicode.org.
Object.RefEq(lit1, lit2): True
Parameter given: This is an IP address: 123.124.125.126
Object.RefEq(lit1, strNew): False
nNote To run this example, you must create a command-line argument in your project properties. On the
Debug tab, add ???This is an IP address: 123.124.125.126??? (including the double quotes) in the Start Options
area.
First, notice the two declarations of the two literal strings lit1 and lit2. The declared
type is String, which is the VB alias for System.String. Clearly, lit1 and lit2 contain strings of
the same value. Based upon what you learned in the previous section, you would expect the
two instances to reference the same string object. In fact, they do, and that is shown in the
output from the program, where you test them using Object.ReferenceEquals().
Finally, this example demonstrates the use of the String.Intern() shared method. If you
want to determine that a string you??™re declaring at run time is already in the intern pool, it
may be more efficient to reference that string rather than create a new instance.


Pages:
261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285
wierszyki katalog stron Internet śmieszne dowcipy Jaki wybrać olej