1. Single Line Comments. Single line comments with // as shown below.
//This is an example for single line comment
2. Multi line comments. Multi line comments with /* */ as shown below.
/*This is a multiple line comment
We are in line 2
Last line of comment*/
3. XML Comments. XML comments with /// as shown below.
///This is an example for defining XML comments.
The type of data that a variable contains is called Data Type (type). A Data Type is a classification of things that share similar type of qualities or characteristics or behavior.
There are two types of data type in C#
However, based on what a variable contains there is two types of built-in data type
A primitive type is a type that has IsPrimitive property set to true. The primitive types are Boolean, Byte, SByte, Int16, UInt16, Int32, UInt32, Int64, UInt64, IntPtr, UIntPtr, Float, Double, Decimal, Char, and Single. All primitive types are value types but not vice versa.
Value types contain the value directly. In other words, the variable refers to the same location in memory where the value is stored. Because of this, when a different variable is assigned the same value, a memory copy of the original variable’s value is made to the location of the new variable. A second variable of the same value type cannot refer to the same location in memory as the first variable. So changing the value of the first variable will not affect the value in the second. Value types are implicitly derived from System.ValueType. A type declared using struct is a value type.
When an object is allocated from the managed heap, the new operator returns the memory address of the object. You usually store this address in a variable. This is called a reference type variable because the variable does not actually contain the object's bits; instead, the variable refers to the object's bits. In short, Reference types store the reference where the data is located instead of storing the data directly. Therefore, to access the data the runtime will read the memory location out of the variable and then jump to the location in memory that contains the data. The memory area of the data a reference type points to is the heap A type declared using class are reference types.
String is not a primitive type. Primitive type cannot be decomposed (i.e they cannot be further broken down) into simpler components. Internally String is represented as an array of characters. So you can decompose String into individual characters. You can't decompose character into smaller values which makes char a primitive type and String a compound type. (String type can be made from char, but char cannot be broken down into any data type. That’s why string is compound type rather than primitive type.)