Giriş
Nullable Yapısı ve Nullable Sınıfı farklı şeyler.
Compare metodu
Şöyle yaparız.
Örnek ver
GetUnderlyingType metodu
Şöyle yaparız.
Nullable Yapısı ve Nullable Sınıfı farklı şeyler.
Compare metodu
Şöyle yaparız.
Nullable.Compare(X, Y);
Equals metoduÖrnek ver
GetUnderlyingType metodu
Şöyle yaparız.
Type t = ...;
t = (Nullable.GetUnderlyingType(t) ?? t);
Şöyle yaparız.PropertyInfo propertyInfo = ...;
if (Nullable.GetUnderlyingType(propertyInfo.PropertyType) == null)
{
//Property is not nullable
// Do whatever you want here
}
Şöyle yaparız.public static bool Is<T>(this T variable,Type type) {
if (var != null) {
Type currentType = variable.GetType();
type = Nullable.GetUnderlyingType(type) ?? type;
while (currentType != typeof(object)) {
if (currentType == type) {
return true;
}
currentType = currentType.BaseType;
}
}
return false;
}
Hiç yorum yok:
Yorum Gönder