O'Reilly logo

Learning C# 2005, 2nd Edition by Brian MacDonald, Jesse Liberty

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Chapter 15: Strings

Quiz

Solution to Question 15–1.

string (lowercase) is the C# keyword that maps to the .NET Framework String class. They may be used interchangeably.

Solution to Question 15–2.
IComparable

Guarantees that strings can be sorted

ICloneable

Guarantees that you can call the Clone method on a string object and get back a new duplicate string

IConvertible

Allows strings to be converted to other types (such as integers)

IEnumerable

Guarantees that strings can be iterated over in foreach loops

Solution to Question 15–3.

A quoted string, provided by the programmer, such as “Hello.”

Solution to Question 15–4.

An escape character embedded in a string indicates that the character or punctuation that follows is to be treated as an instruction rather than as part of the string. \n indicates a new line. \" indicates that the quote symbol is in the string, not terminating it.

Solution to Question 15–5.

Verbatim strings are taken “as is” and thus do not require escape characters. Where \\ would indicate a single backslash in a normal string, in a verbatim string, it indicates two backslashes.

Solution to Question 15–6.

Strings cannot be changed. When you appear to change a string, what actually happens is that a new string is created and the old string is destroyed by the garbage collector if it is no longer referenced.

Solution to Question 15–7.

It is not possible to derive from the String class (or any other sealed class).

Solution to Question 15–8.

You can call the Concat method of the String class, ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required