c####~~~~亟待解决!!

operator2004 2004-07-05 06:43:00
再WINDOWS FORM 中場把十六进制转换成二进制怎么转换????

再FORM上放10个label控件,,然后检测一个16进制数字的状态:
当然,首先要把字符串变成二进制,然后对
这个二进制数进行判断:如果是0 则在FORM的label控件上显示白色,反之,如果是1,显示黑色???
应该怎么做啊!!!在线等!!!
请各位帮忙啊啊!!!
...全文
151 13 打赏 收藏 转发到动态 举报
写回复
用AI写文章
13 条回复
切换为时间正序
请发表友善的回复…
发表回复
operator2004 2004-07-07
  • 打赏
  • 举报
回复
请问://set color to white 部分的代码怎么写?就用10个label,分别为label1,----label10,,,,
demonfox 2004-07-07
  • 打赏
  • 举报
回复
1. “demonfox 你写的 if(binaryStr[i].Equals("0")”
- 少了一个括号,抱歉。

2. “你set color to white,,,那怎么行么”
- 这是Pseudo-code,希望你能了解。

3. “你接受的十六进制的数据并不是固定的,那他的显示状态也是不一样的,你这样不是把他们都定死了么 ”
- 不是很清楚你在讲什么。你?他?你?他们?

4. - 请告诉我,你的“十六进制的数据”在C#中是用什么类型表示的,C#中没有hex这种类型,也许你是用int型来表示的(比如:int x = 0xFF),但是请你明确一下。

5. - 要求帮助的时候,最好能用敬语,比如“请”,“谢谢”等。当然,不是一定要这样,供参考。
vzxq 2004-07-07
  • 打赏
  • 举报
回复
不知道有正则表达示可不可以
demonfox 2004-07-07
  • 打赏
  • 举报
回复
试试这个:http://home.earthlink.net/~yuanyu81/HexTest.zip

如果不是你想要的,那可能我还是没理解你的真正意思,告诉我一声,我再看看。

你的另一个问题我不知道,也许你应该再发一贴,问问别人。
code8110 2004-07-07
  • 打赏
  • 举报
回复
有这么麻烦吗,用数字 (XX & 1)>0)  (XX & 2)>0 (XX & 4)>0 ... 不久可以判断了吗
operator2004 2004-07-07
  • 打赏
  • 举报
回复
demonfox ::
请问:怎样在函数调用前后,设置时间差:如:
TprDriverCall objTPR=new TprDriverCall();
//(1) Call Api: TprDeviceOpen
if("TprDeviceOpen" ==aCaller.FuncName )
{
try
{
OpenData op;
CommonParamData cmpd;
try
{
op =(OpenData)obaParamList[0];
cmpd =(CommonParamData)obaParamList[1];
}
catch
{
throw new System.Exception("Param is not right!");
}
objTPR.TprDeviceOpen(op,out cmpd);
aCaller.DisplayResult(cmpd);
}
catch
{
}
}
再者个函数的前后写???该怎么写???急啊!!!!!
demonfox 2004-07-06
  • 打赏
  • 举报
回复
You said "首先要把字符串变成二进制", so I think the original data is type "String"...

So what's the type of your "十六进制数据"?
wangrong001 2004-07-06
  • 打赏
  • 举报
回复
String str = "ABC"; //your original hex number,
//you said it was type "String", right?
int intStr = Convert.ToInt32(str, 16); //convert to decimal first
String binaryStr = Convert.ToString(intStr, 2); //then convert to binary

for(int i=0; i<binaryStr.Length; i++)
{
if(binaryStr[i].Equals("0")
//set color to white
else
//set color to black
}

operator2004 2004-07-06
  • 打赏
  • 举报
回复
不是字符串,是十六进制数据
mnbvchunter 2004-07-06
  • 打赏
  • 举报
回复
UP
gOODiDEA 2004-07-06
  • 打赏
  • 举报
回复
UnicodeEncoding unicodeEncoding = new UnicodeEncoding();
byte [] bOut = unicodeEncoding.GetBytes( inputString );
for( int i = 0; i < bOut.Length; i++ )
{
string x = bOut[i].ToString("X");
demonfox 2004-07-06
  • 打赏
  • 举报
回复
String str = "ABC"; //your original hex number,
//you said it was type "String", right?
int intStr = Convert.ToInt32(str, 16); //convert to decimal first
String binaryStr = Convert.ToString(intStr, 2); //then convert to binary

for(int i=0; i<binaryStr.Length; i++)
{
if(binaryStr[i].Equals("0")
//set color to white
else
//set color to black
}
operator2004 2004-07-06
  • 打赏
  • 举报
回复
demonfox 你写的 if(binaryStr[i].Equals("0")
这个地方有问题,要不然你看看
我上面说的已经改正了,是直接把十六进制的数据,转换成二进制!!!!
然后再显示他们的状态
!!!
你set color to white,,,那怎么行么

你接受的十六进制的数据并不是固定的,那他的显示状态也是不一样的,你这样不是把他们都定死了么

110,538

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • Web++
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧