title: How to set the value of nullable property using PropertyInfo.SetValue Method (Object, Object)
body: <p>Here is my Code. It's throwing exception "Object of type 'MyEnum.CommonCoreStandard' cannot be converted to type 'System.Nullable`1[System.Byte]'." while setting the value of second property "Prop2". I am using the concept of reflection to convert one type "BlEntity" into another type "UiEntity"</p>
  
  <pre><code>public class BlEntity
  {
      //CommonCoreStandard is an enum
      public CommonCoreStandard Prop1 { get; set; }
      public CommonCoreStandard? Prop2 { get; set; }
  }
  
  public class UiEntity
  {
      public byte Prop1 { get; set; }
      public byte? Prop2 { get; set; }
  }
  
   public void ConvertBlToUi()
      {
          var source = new BlEntity(CommonCoreStandard.KeyIdeasAndDetails, CommonCoreStandard.IntegrationOfKnowledge);
          var target = new UiEntity();
  
          TypeConverter.ConvertBlToUi(source,target);
   }
  
      public static void ConvertBlToUi&lt;TBl, TUi&gt;(TBl entitySource, TUi entityTarget)
      {
          var blProperties = typeof(TBl).GetProperties().Select(p =&gt; new { Name = p.Name.ToLower(), Property = p }).ToArray();
  
          var uiProperties = typeof(TUi).GetProperties().Select(p =&gt; new { Name = p.Name.ToLower(), Property = p });
  
          foreach (var uiProperty in uiProperties)
          {
              var value = blProperty.Property.GetValue(entitySource);
              uiProperty.Property.SetValue(entityTarget, value);
          }
  
      }
  </code></pre>