我在.NET中得到结果,如下所示:
var lastRowVersion = sqlHelper.ExecuteScalar(connStr,CommandType.Text,"select top 1 rowversion from dbo.sdb_x_orginfo order by rowversion desc");
结果是一个字节数组[0] = 0,[1] = 0,[2] = 0,[3] = 0,[4] = 0,[5] = 0,[6] = 30,[7 ] = 138,但sql Server中的结果为0x0000000000001E8A.
如何在.NET中获取值“0x0000000000001E8A”?
@H_403_8@解决方法
如果您只想将byte []转换为System.Int64(又名long),则使用
BitConverter.ToInt64
:
sqlBinary binary = /* ... */; long value = BitConverter.ToInt64(binary.Value,0); // 0 is the start index in the byte array
要将其显示为十六进制字符串,可以使用X format specifier,例如:
Console.WriteLine("Value is 0x{0:X}.",value);@H_403_8@ @H_403_8@ 原文链接:https://www.f2er.com/csharp/93221.html