如何将字节发送到方法? [英] how to send the bytes to a methods ?
本文介绍了如何将字节发送到方法?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
namespace sonar_proj
{
public partial class son : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
char[] a = new char[10];
char y = conversion(byte );
private byte conversion(byte binval)
{
binval =(byte)~binval;
byte temp = (byte)(((binval & 0xf0)>>4) |(byte)((binval &0x0f)<<4) );
return temp;
}
its showin some error . can u plz sort out this error
推荐答案
1)您不能在另一个方法的中间声明一个方法.
将其移到Page_Load事件之外,一切都应该没问题.
2)您不能将类byte
作为参数传递给转换例程-您需要传递一个值.
1) You can''t declare a method in the middle of another method.
Move it outside the Page_Load event, and all should be fine.
2) You can''t pass a classbyte
as a parameter to your conversion routine - you need to pass a value instead.
在此处阅读有关字节的信息:MSDN:字节 [
Read about Byte here: MSDN: Byte[^]
Example:
byte myByte = 255;
// For your program
char y = conversion(myByte);
char
用于字符.byte
用于数字.根据我在这里阅读的内容,您仅在处理数字.因此,暂时完全忘记char
并将其全部更改为byte
.
然后,您有
char
is for characters.byte
is for numbers. From what I have read here, you''re dealing with numbers only. So forget aboutchar
completely for now and change it all tobyte
.
Then you have
byte y = conversion(byte );
,该方法不起作用,因为您将类型作为参数传递,且期望的值类型为byte
.更改为
, which doesn''t work because you pass a type as parameter where a value of type byte
is expected. Change to
byte y = conversion(0x42);
.
"42"代表一些值.我不知道您真的要转换.将所需的内容放在convert()
的括号之间.
.
The "42" represents some value. I don''t know what you really want to convert. Put whatever you want between the brackets of convert()
.
这篇关于如何将字节发送到方法?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文