using System.Collections.Generic;
using System.Text.RegularExpressions;
using Microsoft.Extensions.Logging;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
public static void Main()
var partnerId = GetValueBad<int?>();
Console.WriteLine(partnerId.Value);
public static T GetValue<T>()
var genericValue = 33591572;
if (t.IsGenericType && t.GetGenericTypeDefinition().Equals(typeof(Nullable<>)))
t = Nullable.GetUnderlyingType(t);
if (genericValue == null) return default;
return (T)Convert.ChangeType(genericValue, t);
public static T GetValueBad<T>()
var genericValue = 33591572;
if (genericValue == null) return default;
return (T)Convert.ChangeType(genericValue, typeof(T));