The default operator can be used to determine the default value for any type. It returns values as follows:
- For value types – the result of zeroing out the contents of the variable
- Numeric types – zero
- bool type – false
- char type – null character
- struct types – all fields defaulted
- For reference types – null
Here are some examples:
1 2 3 4 5 6 7 | int n1 = default(int); // 0double d1 = default(double); // 0.0bool b1 = default(bool); // falsechar c1 = default(char); // \0string s1 = default(string); // nullDog d = default(Dog); // null (ref type)Point3D p1 = default(Point3D); // X=0.0, Y=0.0, Z=0.0, Name=null |

