Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

is java byte the same as C# byte?

Native method from dll works in java if the input parameter is array of bytes - byte[]. 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#?

like image 908
Sergey Avatar asked Jun 03 '11 04:06

Sergey


People also ask

What is a byte in 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.

How much is a byte in Java?

A byte in Java is 8 bits. It is a primitive data type, meaning it comes packaged with Java. Bytes can hold values from -128 to 127.

Is a char a byte in Java?

A char represents a character in Java (*). It is 2 bytes large (or 16 bits).


2 Answers

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.

C# key words

more for c# Byte

like image 109
huoxudong125 Avatar answered Sep 28 '22 05:09

huoxudong125


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.

like image 32
evilone Avatar answered Sep 28 '22 05:09

evilone