Convert C # data type to equivalent java data type

I have several data types used in C # that I need to translate to Java.

uint , Int16 , UInt16 , Nullable<Int16>

What would be the appropriate data type for them in Java?

+6
java c #
source share
3 answers

Although the link provided by x2 is good, this is not all that is useful when dealing with unsigned primitives. For example: an int range is 2,147,483,648 to 2,147,483,647 (which is the same in both languages), but the C # s uint range is from 0 to 4,294,967,295. Java does not have a similar primitive type, so you have to use something that contains this range (in this case, long).

If you are only concerned about one-way compatibility (C # to Java), they should work:

  • C # → java
  • uint → long
  • Int16 → short
  • UInt16 → short
  • Nullable -> look at classes that wrap primitive types (i.e. Integer wraps int)

EDIT :: I just found this article on MSDN about the differences between data types in two languages .

+6
source share

Data type equivalents between Java and C #. I hope you can find out.

enter image description here

+5
source share
+4
source share

All Articles