Game Development Reference
In-Depth Information
spriteBatch.DrawString(gameFont, "Hello, how are you doing?",
Vector2.Zero, Color.Green);
11.6 Characters, Strings and Type Conversion
11.6.1 The char Type
The text that we draw on the screen using the DrawString method has a type called
string .The string type is used in C# to represent text (consisting of multiple charac-
ters, punctuation marks and so on). There is also a primitive type called char .This
type contains only a single character. Just like the other primitive types like int or
double , char values can be stored in variables, they can be passed as a parameter to a
method, they can be part of an object, and so on. There is a special kind of notation
to indicate that something is a char value: by enclosing the character in singe quotes .
This is different from string values, which use double quotes :
char asterisk;
string dashes;
asterisk = '
';
−−−−−−−−
dashes = "
";
Between single quotations you can place only a single symbol; between double
quotations you can place multiple symbols, or a single symbol, or even no symbols
at all. Next to char and string values, other constant values can be numbers, boolean
values, or null , as expressed in this syntax diagram:
 
Search WWH ::




Custom Search