从byte数组byte[]转换为bitmapsource以及反射实现属性批量赋值

从byte数组byte[]转换为bitmapsource

(BitmapSource)new ImageSourceConverter().ConvertFrom(b)

名字有规律的属性代码用反射优美实现

  for(int i=0;i<imageList.Tables[0].Rows.Count;i++)
                {
                      if(imageList.Tables[0].Rows[i]!=null)
                      {
                            System.Data.DataRow tab = imageList.Tables[0].Rows[i];
                            BitmapSource source=(BitmapSource)new ImageSourceConverter().ConvertFrom((byte[])tab.ItemArray[0]);
                            System.Reflection.PropertyInfo propertyInfo=this.GetType().GetProperty("Image" + (i + 1));
                            propertyInfo.SetValue(this, source, null);
                      }                  
                   
                }           
原文地址:https://www.cnblogs.com/ssvip/p/9774226.html