object nullableObject = (int?)2; // nullable int, but we do not know var type = Nullable.GetUnderlyingType(nullableObject.GetType()) ?? nullableObject.GetType(); // get the underlying type (int) var nonNullableObject = Convert.ChangeType(nullableObject, type); // convert int? to int
271300cookie-checkC# convert nullable to non-nullable (with reflection)