[英]Equivalent System.Data.Linq.Binary in .net core
誰能幫助我在.net core中轉換此代碼:
private static string GetValueFromModelValue(object formValue)
{
//Test to determine if its binary data. If it is, we need to convert it to a base64 string.
Binary binaryValue = formValue as Binary;
if (binaryValue != null)
{
formValue = binaryValue.ToArray();
}
//If the above conversion to an array worked, then the following will cast as a byte array and convert.
byte[] byteArrayValue = formValue as byte[];
if (byteArrayValue != null)
{
formValue = Convert.ToBase64String(byteArrayValue);
}
return formValue.ToString();
}
System.Data.Linq
中的類型在.NET Core和.NET Standard版本(當前為1.0-2.0)中不可用。
由於沒有調用者可以傳遞.NET Core上的Binary
對象,因此您可以刪除代碼或將其放入預處理器定義中(此示例假定針對.NET Core 1.1進行構建):
#if !NETCOREAPP1_1
Binary binaryValue = …
if (binaryValue != null)
{
…
}
#endif
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.