将两行从java转换为C# [英] Convert two lines from java to C#

查看:56
本文介绍了将两行从java转换为C#的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好



有人可以将此代码从java转换为c#。



Hello

someone could convert this code from java to c#.

sb2.Append(String.Format("-%02X", new Object[] { Byte.valueOf(b1) }));
  sb2.Append(String.Format("%02X", new Object[] { Byte.valueOf(b2) }));





谢谢

问候



我尝试了什么:





thanks
regards

What I have tried:

the problem is the byte.valueof… i dont know how to express it in c#

推荐答案

请参阅:Convert.ToByte方法 [ ^ ]


尝试 Byte.TryParse方法(系统)| Microsoft Docs [ ^ ]

Try Byte.TryParse Method (System) | Microsoft Docs[^]
string b1 = "+120";
byte b1b;
if (!byte.TryParse(b1, out b1b)) return;

然后在你的数组中使用 bib

或更好:

Then use bib in your array.
Or better:

string b1 = "+120";
byte b1b;
if (!byte.TryParse(b1, out b1b)) return;
sb2.AppendFormat(


- {b1b:X2} );
"-{b1b:X2}");


这篇关于将两行从java转换为C#的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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