![](/img/trans.png)
[英]Migrating working ServiceStack to live causes Unable to cast object of type 'System.Byte' to type 'System.String'
[英]Unable to cast object of type 'System.String' to type 'System.Byte[]'. Why?
將圖像從DataGridView
到PictureBox
時遇到問題,出現以下錯誤
無法將類型為“ System.String”的對象轉換為類型為“ System.Byte []”的對象
這是我的代碼:
Private Sub BindToText()
With dgv_EmployeeMainFile
...
Dim bytes As [Byte]() = .CurrentRow.Cells(31).Value
Dim ms As New MemoryStream(bytes)
PictureEmp.Image = Image.FromStream(ms)
End With
End Sub
假設Cells(31)包含Unicode字符,則可以使用:
System.Text.Encoding.Unicode.GetBytes(str)
供參考: https : //www.dotnetperls.com/convert-string-byte-array-vbnet
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.