mikebai.com

  • Home
  • dev
  • DotNET
  • M365
  • 搞笑
  • 杂七杂八
  • FocusDict
個人BLOG
it developer
  1. Main page
  2. dev
  3. Main content

.NET和Java中BYTE的区别

2011-06-19 105hotness 0likes 0comments

1.有符号和无符号
 c#中字节byte的范围是0~255;
 java中字节byte的范围是-128~127:


2.高低位顺序不同
 比如16位整数10用16进制000A,在.net转换成byte数组是00 0A,而java/flash/flex等转换是0a 00



NET 转JAVA


BitConverter.ToInt32(bytes, 0);(C#)


JAVA:
public static int ToInt32(byte[] bytes, int startIndex)
 {
   int l = (int) bytes[startIndex] & 0xFF;
   l += ((int) bytes[startIndex + 1] & 0xFF) << 8;
   l += ((int) bytes[startIndex + 2] & 0xFF) << 16;
   l += ((int) bytes[startIndex + 3] & 0xFF) << 24;
   return l;
 }

Tag: Nothing
Last updated:2011-06-19

mikebai

This person is a lazy dog and has left nothing

Like
< Last article
Next article >

COPYRIGHT © 2025 mikebai.com. ALL RIGHTS RESERVED.

Theme Kratos Made By Seaton Jiang