Equivalent of getBytes() in Java to C#

后端 未结 3 1493
迷失自我
迷失自我 2021-01-21 07:51

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

相关标签:
3条回答
  • 2021-01-21 08:08

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

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

    For reference see http://msdn.microsoft.com/en-us/library/ds4kkd55.aspx

    0 讨论(0)
  • 2021-01-21 08:12

    you should use UTF8Encoding.GetBytes() (or GetBytes method of some other encoding, if your string is not UTF8 encoded)

    0 讨论(0)
  • 2021-01-21 08:17

    It could be:

    Bytes[] byteAray = Encoding.GetBytes(paramString);
    

    From Microsoft site

    0 讨论(0)
提交回复
热议问题