Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

convert c# datatype to equivalent java datatype

Tags:

java

c#

I have few datatypes used in C# that I need to translate to Java.

uint, Int16, UInt16, Nullable<Int16>

What will be the appropriate datatype for these in Java?

like image 997
user206646 Avatar asked Mar 16 '11 09:03

user206646


People also ask

How do you convert C to F fast?

To convert temperatures in degrees Celsius to Fahrenheit, multiply by 1.8 (or 9/5) and add 32.

How do you convert temperature to degrees Celsius?

The formula for converting Fahrenheit to Celsius is C = 5/9(F-32). Fahrenheit and Celsius are the same at -40°. At ordinary temperatures, Fahrenheit is a larger number than Celsius. For example, body temperature is 98.6 °F or 37 °C.

What is type conversions in C?

In C programming, we can convert the value of one data type ( int, float , double , etc.) to another. This process is known as type conversion.

What is Celsius vs Fahrenheit?

The Conversion This means Celsius is 1.8 times larger than Fahrenheit. To put another way, 1 degree Fahrenheit is 5/9 degree Celsius. Despite the pretty large differences between one another, these two temperature scales intersect at -40 degrees, meaning that -40 degrees Fahrenheit is the same as -40 degrees Celsius.


2 Answers

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

If you are only worried about 1-way compatibility (C# to Java) these should work:

  • c# --> java
  • uint --> long
  • Int16 --> short
  • UInt16 --> short
  • Nullable --> look into the classes that wrap the primitive types (i.e. Integer wraps an int)

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

like image 54
RKitson Avatar answered Sep 19 '22 23:09

RKitson


Data type equivalents between Java and C#. Hope you can find it out.

enter image description here

like image 23
Praveen Avatar answered Sep 20 '22 23:09

Praveen