default Operator C# with Example



default Operator C# with Example

Value Type (where T : struct) 
The built-in primitive data types, such as char, int, and float, as well as user-defined types declared with struct, 
or enum. Their default value is new T() : 
default(int) // 0 
//  0001-01-01  12:00:00  AM 
default(DateTime) 
// '\0' This is the "null character", not a zero or a line break. 
default(char) 
// 00000000-0000-0000-0000-000000000000 
default(Guid) 
default(MyStruct) //  new  MyStruct() 
// Note: default of an enum is 0, and not the first *key* in that enum 
// so it could potentially fail the Enum.IsDefined test 
default(MyEnum) //  (MyEnum)0 
Reference Type (where T : class) 
Any class, interface, array or delegate type. Their default value is null : 
default(object) // null 
// null 
default(string) 
// null 
default(MyClass) 
// null 
default(IDisposable) 
// null 
default(dynamic) 

0 Comment's

Comment Form

Submit Comment