This article is a mirror article of machine translation, please click here to jump to the original article.

View: 3170|Reply: 0

[Source] .NET converts the database varbinary string into a byte[] array

[Copy link]
Posted on 10/31/2023 9:09:35 PM | | | |
Requirements: The database field type is varbinary(MAX), and the database query shows 0x..., in fact, the field information can be read directly to byte[] through ADO.NET, but I want to convert the varbinary(MAX) string into a byte[] array through code.

C# BYTE[] and hexadecimal strings are converted to each other
https://www.itsvse.com/thread-10039-1-1.html

The varbinary(MAX) query is displayed in the format:0x[hexString 16 String]

The code is as follows:

First, the first 2 bits of the string need to be removed,Save the converted byte[] as an image, and then compare it with the original image, and the file is exactly the same, as shown in the figure below:



(End)





Previous:[Practical combat] Use Lucene.Net + Jieba.NET to build a lightweight in-site search
Next:EF concurrency exception DbUpdateConcurrencyException requeries the cached value
Disclaimer:
All software, programming materials or articles published by Code Farmer Network are only for learning and research purposes; The above content shall not be used for commercial or illegal purposes, otherwise, users shall bear all consequences. The information on this site comes from the Internet, and copyright disputes have nothing to do with this site. You must completely delete the above content from your computer within 24 hours of downloading. If you like the program, please support genuine software, purchase registration, and get better genuine services. If there is any infringement, please contact us by email.

Mail To:help@itsvse.com