Generic types default value in C#
Forums:
class Size<T> {
public T Width { get; set; }
public T Height { get; set; }
public void Reset() {
Width = default(T);
Height = default(T);
}
}
var sizeInt = new Size<int>{Width = 5, Height = 9};
sizeInt.Reset();
//Width is 0 and Height is 0
- Log in to post comments