如何将二进制编码的十六进制字节数组转换为字节 [英] How to Convert Binary Coded Hex Byte Array to Byte

查看:78
本文介绍了如何将二进制编码的十六进制字节数组转换为字节的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我认为这将是直截了当的,因为在.NET中有丰富的转换功能,但事实证明它比想象的更糟糕。

想象。给予以下


< code>

Dim ba(1)As Byte

Dim b As Byte


ba(0)=& h4

ba(1)=& h0


b = foo(ba)

< / code>


什么是foo(),b包含& h40?


TIA


Charles

[我可以为此编写一个算法,但必须有一个简洁的

为它转换]

I thought this was going to be straight forward, given the wealth of
conversion functions in .NET, but it is proving more convoluted than
imagined.

Given the following

<code>
Dim ba(1) As Byte
Dim b As Byte

ba(0) = &h4
ba(1) = &h0

b = foo(ba)
</code>

What is foo() such that b contains &h40 ?

TIA

Charles
[I could write an algorithm for this, but there must surely be a succinct
conversion for it]

推荐答案

*" Charles Law" < BL *** @ nowhere.com> scripsit:
* "Charles Law" <bl***@nowhere.com> scripsit:
考虑到.NET中丰富的转换功能,我认为这将是直截了当的,但事实证明它比想象的更复杂。

给出以下内容

< code>
Dim ba(1)As Byte
Dim b As Byte

ba(0 )=& h4
ba(1)=& h0

b = foo(ba)
< / code>

什么是foo()这样b包含& h40?

TIA

[我可以为此写一个算法,但肯定有一个简洁的
转换它]
I thought this was going to be straight forward, given the wealth of
conversion functions in .NET, but it is proving more convoluted than
imagined.

Given the following

<code>
Dim ba(1) As Byte
Dim b As Byte

ba(0) = &h4
ba(1) = &h0

b = foo(ba)
</code>

What is foo() such that b contains &h40 ?

TIA

Charles
[I could write an algorithm for this, but there must surely be a succinct
conversion for it]




可以有很多功能...


\\\

公共功能Foo(ByVal abyt()As Byte)As Byte

返回& H40

结束功能

///


SCNR


-

Herfried K. Wagner [MVP]

< URL:http://dotnet.mvps.org/>



There can be many functions...

\\\
Public Function Foo(ByVal abyt() As Byte) As Byte
Return &H40
End Function
///

SCNR

--
Herfried K. Wagner [MVP]
<URL:http://dotnet.mvps.org/>


Hi Herfried

当我正在煮咖啡时,我发现了自己的错误(在帖子中)。它应该是


< code>

Dim ba(1)As Byte

Dim b As Byte


ba(0)=& h34

ba(1)=& h30


b = foo(ba)

< / code>


仍然在寻找foo(),这样b包含& h40。


Charles

" Herfried K. Wagner [MVP]" <喜*************** @ gmx.at>在消息中写道

news:Oc ************* @ TK2MSFTNGP11.phx.gbl ...
Hi Herfried

As I was making coffee I realised my mistake (in the post). It should read

<code>
Dim ba(1) As Byte
Dim b As Byte

ba(0) = &h34
ba(1) = &h30

b = foo(ba)
</code>

Still looking for foo() such that b contains &h40.

Charles
"Herfried K. Wagner [MVP]" <hi***************@gmx.at> wrote in message
news:Oc*************@TK2MSFTNGP11.phx.gbl...
*" Charles Law" < BL *** @ nowhere.com> scripsit:
* "Charles Law" <bl***@nowhere.com> scripsit:
考虑到.NET中丰富的转换功能,我认为这将是直截了当的,但事实证明它比想象的更复杂。

给出以下内容

< code>
Dim ba(1)As Byte
Dim b As Byte

ba(0 )=& h4
ba(1)=& h0

b = foo(ba)
< / code>

什么是foo()这样b包含& h40?

TIA

[我可以为此写一个算法,但肯定有一个
简洁转换]
I thought this was going to be straight forward, given the wealth of
conversion functions in .NET, but it is proving more convoluted than
imagined.

Given the following

<code>
Dim ba(1) As Byte
Dim b As Byte

ba(0) = &h4
ba(1) = &h0

b = foo(ba)
</code>

What is foo() such that b contains &h40 ?

TIA

Charles
[I could write an algorithm for this, but there must surely be a succinct conversion for it]



可以有很多功能...

\\\
Public Function Foo(ByVal) abyt()As Byte)作为Byte
返回&H40
结束功能
///

SCNR

-
Herfried K. Wagner [MVP]
< URL:http://dotnet.mvps.org/>



There can be many functions...

\\\
Public Function Foo(ByVal abyt() As Byte) As Byte
Return &H40
End Function
///

SCNR

--
Herfried K. Wagner [MVP]
<URL:http://dotnet.mvps.org/>



更正


给出以下


< code>

Dim ba(1)As Byte

Dim b As Byte


ba(0)=& h34

ba(1)=& h30


b = foo(ba)

< / code>


什么是foo(),b包含& h40?


TIA

Charles

" Charles Law" < BL *** @ nowhere.com>在消息中写道

news:uy ************** @ TK2MSFTNGP09.phx.gbl ...
Correction

Given the following

<code>
Dim ba(1) As Byte
Dim b As Byte

ba(0) = &h34
ba(1) = &h30

b = foo(ba)
</code>

What is foo() such that b contains &h40 ?

TIA

Charles
"Charles Law" <bl***@nowhere.com> wrote in message
news:uy**************@TK2MSFTNGP09.phx.gbl...
我以为这是去的为了直截了当,给出了.NET中丰富的转换功能,但事实证明它比想象的更复杂。

给出以下内容
< code>
Dim ba(1)As Byte
Dim b As Byte

ba(0)=& h4
ba(1)=& ; h0

b = foo(ba)
< / code>

什么是foo(),b包含& h40?

TIA

Charles
[我可以为此写一个算法,但肯定会有简洁的转换]
I thought this was going to be straight forward, given the wealth of
conversion functions in .NET, but it is proving more convoluted than
imagined.

Given the following

<code>
Dim ba(1) As Byte
Dim b As Byte

ba(0) = &h4
ba(1) = &h0

b = foo(ba)
</code>

What is foo() such that b contains &h40 ?

TIA

Charles
[I could write an algorithm for this, but there must surely be a succinct
conversion for it]



这篇关于如何将二进制编码的十六进制字节数组转换为字节的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆