C#將字節(jié)數(shù)組轉(zhuǎn)換成數(shù)字的方法
更新時間:2015年04月04日 12:44:25 作者:令狐不聰
這篇文章主要介紹了C#將字節(jié)數(shù)組轉(zhuǎn)換成數(shù)字的方法,涉及C#類型轉(zhuǎn)換的技巧,非常具有實用價值,需要的朋友可以參考下
本文實例講述了C#將字節(jié)數(shù)組轉(zhuǎn)換成數(shù)字的方法。分享給大家供大家參考。具體實現(xiàn)方法如下:
// Create a decimal from a byte array public static decimal ByteArrayToDecimal (byte[] src) { // Create a MemoryStream containing the byte array using (MemoryStream stream = new MemoryStream(src)) { // Create a BinaryReader to read the decimal from the stream using (BinaryReader reader = new BinaryReader(stream)) { // Read and return the decimal from the // BinaryReader/MemoryStream return reader.ReadDecimal(); } } }
希望本文所述對大家的C#程序設計有所幫助。
相關(guān)文章
C#連接到sql server2008數(shù)據(jù)庫的實例代碼
這篇文章主要介紹了C#連接到sql server2008數(shù)據(jù)庫的實例代碼,需要的朋友可以參考下2017-09-09