C# Reflection: How to get the type of a Nullable?

I’ve been using the following type of code to check if the type is nullable and to get the actual type: if (type.IsGenericType && type.GetGenericTypeDefinition() == typeof(Nullable<>)) { return Nullable.GetUnderlyingType(type); } If the type is e.g. Nullable this code returns the int part (underlying type). If you just need to convert object into specific type … Read more

Nullable type is not a nullable type?

According to the MSDN : Calling GetType on a Nullable type causes a boxing operation to be performed when the type is implicitly converted to Object. Therefore GetType always returns a Type object that represents the underlying type, not the Nullable type. When you box a nullable object, only the underlying type is boxed. Again, … Read more

Android get type of a view

If, for some strange reason, you can’t use Asahi‘s suggestion (using tags), my proposition would be the following: if (view instanceof ImageView) { ImageView imageView = (ImageView) view; // do what you want with imageView } else if (view instanceof TextView) { TextView textView = (TextView) view; // do what you want with textView } … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)