本文介绍了的getBytes()在Java中C#的等效的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想转换一个类是Java到C#,大部分的修改都已经完成,但我有这个部分,我真的不知道的。我想这行code的转换:

I want to convert a class which is in Java to C#, most of the changes are done already but I have this part which I am not really sure about. I want to convert this line of code:

byte[] arrayOfByte1 = paramString.getBytes();

我已经试过这样:

I have tried this:

byte[] arrayOfByte1 = BitConverter.GetBytes(paramString);

不过,这并不为GetBytes会工作()期待一个双。我不知道,如果只是将其转换为双就解决了问题,所以我想在这里问一下吧。

But it does not work as GetBytes() is expecting a double. I am not sure if just converting it to a double would solve the issue, so I wanted to ask about it here.

推荐答案

根据您的编码,你这样做类似以下内容:

Depending on your encoding you do this similar to the following:

byte[] arrayOfByte1 = Encoding.UTF8.GetBytes (paramString);

有关更多信息参见

这篇关于的getBytes()在Java中C#的等效的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-19 00:39