繁体   English   中英

.NET Core中的等效System.Data.Linq.Binary

[英]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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM