In my table there is a column with datatype of timestamp. Using entity framework I can get the value of this timestamp value and it's a byte[] value.
Once this value is sent to view, it's generate a string value. (I'm using razor engine)
My byte[] is [0,0,0,0,0,1,159,44] and once it converted to string using razor it's like AAAAAAABnyw=
My question is how this string value be like this? What's the encoding method used by the razor?
How do I get this string value from byte[8] using C#?
What's the encoding method used by the razor?
Well that just looks like Base64 to me:
byte[] x = {0, 0, 0, 0, 0, 1, 159, 44};
Console.WriteLine(Convert.ToBase64String(x));
Output: AAAAAAABnyw=
You can go the other way with Convert.FromBase64String
.
Alternatively, you might want to use BitConverter.ToInt64
to retrieve the original 64-bit integer which corresponds to rowversion
, I believe.
See more on this question at Stackoverflow