IsEmpty / IsNotEmpty
Checks if any value type is empty.
Source
public static bool IsEmpty<T>(this T value) where T : struct {
return value.Equals(default(T));
}
public static bool IsNotEmpty<T>(this T value) where T : struct {
return (value.IsEmpty() == false);
}
Example
var dt = DateTime.MinValue;
if(dt.IsEmpty()) {
...
}
Author: Patrick A. Lorenz
Submitted on: 19 mrt. 2008
Language: C#
Type: System.ValueType
Views: 6751