I. type conversion
1. Implicit conversions 2. Explicit conversions 2. Enumeration 1. Defining Enum typename: underlyingType {Value1, Value2, Value3 ,....} The basic enumeration types include bytes, sbyte, short, ushort, int, uint, long, And ulong:
Namespace Ch05Ex02
{
// Define Enumeration
Enum oritentation: byte
{
North = 1,
South = 2,
East = 3,
West = 4,
}
Class Program
{
Static void Main (string [] args)
{
Byte diByte;
String diString;
DiByte = (byte) oritentation. north; // display conversion. Even if the basic oritentation type is byte, (byte) data type conversion is still required.
DiString = Convert. ToString (oritentation. north); // you can use the ToString () command to obtain the enumerated string value.
Console. WriteLine ("Byte = {0}", diByte );
Console. WriteLine ("String = {0}", diString );
Console. ReadKey ();
}
}
}
3. The structure is a data structure composed of several data types. Define the structure Struct <typename >{< access modifier> <basic type> <name >}iv. array declaration array <basetype> [] <name> <basetype> Any Type the array must be initialized before access, initialization can be divided into two types: Specify the array content literally, or specify the array size, for example: int [] myIntArray = {5, 9,}; 2, use the keyword new to initialize all array elements. Example: int [] myIntArray = new int [5]; multi-dimensional array <basetype> [,] <name> // define a two-dimensional array multi-dimensional array with more commas, for example, <basetype> [,] <name> // declares a 4-dimensional array. 5. string processing <string>. toLower () converts string to uppercase <string>. toUpper () converts a string to lowercase <string>. trim () deletes spaces in the input string <string>. trimStart () deletes the space before the string <string>. trimEnd () removes spaces after a string <string>. padLeft () adds a space on the left of the string <string>. padRight () adds a space to the right of the string <string>. split () converts a string to a string array <string>. replace (string oldValue, string newValue) replaces string with another specified string