razor 如何将字节 [8] 转换为字符串?

How razor convert byte[8] to string?

在我的 table 中有一个数据类型为时间戳的列。使用 entity framework 我可以获得这个时间戳值的值,它是一个 byte[] 值。

一旦将此值发送到视图,它就会生成一个字符串值。 (我正在使用剃须刀引擎)

我的 byte[] 是 [0,0,0,0,0,1,159,44],一旦使用剃刀将其转换为字符串,它就像 AAAAAAABnyw=

我的问题是这个字符串值是怎么变成这样的? 剃须刀使用的编码方式是什么?

如何使用 C# 从 byte[8] 中获取此字符串值?

What's the encoding method used by the razor?

好吧,我觉得这就像 Base64:

byte[] x = {0, 0, 0, 0, 0, 1, 159, 44};
Console.WriteLine(Convert.ToBase64String(x));

输出:AAAAAAABnyw=

你可以选择 Convert.FromBase64String 的另一条路。

或者,您可能想使用 BitConverter.ToInt64 to retrieve the original 64-bit integer which corresponds to rowversion,我相信。