开发者

is java byte the same as C# byte?

Native method from dll works in java if the input parameter is array of bytes - byt开发者_Python百科e[]. If we use the same method from c# it throws EntryPointNotFoundException.

Is that because of byte[] in java and c# are different things? and if it's so how should I use native function from c#?


Java lacks the unsigned types. In particular, Java lacks a primitive type for an unsigned byte. The Java byte type is signed, while the C# byte is unsigned and sbyte is signed.


Is that because of byte[] in java and c# are different things?

Yes.

  • Endianness: Java stores things internally as Big Endian, while .NET is Little Endian by default.
  • Signedness: C# bytes are unsigned. Java bytes are signed.

See different results when converting int to byte array - .NET vs Java.


What's the signature of the native function? How do you declare it in Java and in C#?

The most common reason for EntryPointNotFoundException is that function name is mangled (esp. true if function is written in C++) or misspelled.

Another source of problem is 'W' and 'A' suffixes for WinAPI function used to distinguish ANSI and Unicode versions of functions. .NET interop mechanism can try to guess the function suffix, so that may be the source of confusion,


Java Byte:

java byte: The byte data type is an 8-bit signed two's complement integer. It has a minimum value of -128 and a maximum value of 127 (inclusive). The byte data type can be useful for saving memory in large arrays, where the memory savings actually matters. They can also be used in place of int where their limits help to clarify your code; the fact that a variable's range is limited can serve as a form of documentation.

more for Java Byte

C# Byte

Byte Represents an 8-bit unsigned integer,Byte is an immutable value type that represents unsigned integers with values that range from 0 (which is represented by the Byte.MinValue constant) to 255 (which is represented by the Byte.MaxValue constant). The .NET Framework also includes a signed 8-bit integer value type, SByte, which represents values that range from -128 to 127.

is java byte the same as C# byte?

more for c# Byte

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜