An array stores a fixed-size sequential collection of elements of the same type. An array is used to store a collection of data, but it is often more useful to think of an array as a collection of variables of the same type stored at contiguous memory locations. Instead of declaring individual variables, such as number0, number1, ..., and number99, you declare one array variable such as numbers and use numbers[0], numbers[1], and ..., numbers[99] to represent individual variables. A specific element in an array is accessed by an index. All arrays consist of contiguous memory locations. The lowest address corresponds to the first element and the highest address to the last element. Declaring Arrays To declare an array in C#, you can use the following syntax − datatype[] arrayName; where, datatype is used to specify the type of elements in the array. [ ] specifies the rank of the array. The rank specifies the size of the array. arrayName specifies the name of the
C# provides a special data types, the nullable types, to which you can assign normal range of values as well as null values. C# Methods For example, you can store any value from -2,147,483,648 to 2,147,483,647 or null in a Nullable<Int32> variable. Similarly, you can assign true, false, or null in a Nullable<bool> variable. Syntax for declaring a nullable type is as follows: < data_type> ? <variable_name> = null; The following example demonstrates use of nullable data types: using System ; namespace CalculatorApplication { class NullablesAtShow { static void Main ( string [] args ) { int ? num1 = null ; int ? num2 = 45 ; double ? num3 = new double ?(); double ? num4 = 3.14157 ; bool ? boolval = new bool ?(); // display the values Console . WriteLine ( "Nullables at Show: {0}, {1}, {2}, {3}" , num1 , num2