Contents - Cultural View
Contents - Cultural View
Contents - Cultural View
You also want an ePaper? Increase the reach of your titles
YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.
Comparison of Java and C Sharp 64<br />
decimal Decimal<br />
128 ±1.0 × 10e−28 to ±7.9 × 10e28 Not<br />
available<br />
Not available<br />
char Char 16 \u0000 to \uFFFF char Character<br />
bool Boolean 8 true, false boolean Boolean<br />
Advanced numeric types<br />
Both languages offer library-defined arbitrary size integer types.<br />
Only Java offers a data type for arbitrary precision decimal point calculations and only C# offers a type for working<br />
with complex numbers.<br />
In both languages the number of operations which can be performed are limited compared to the built-in IEEE 754<br />
floating point types. For instance, none of the types support square root or logarithms.<br />
By leveraging the C# support for type integration through custom operator overloading and custom (implicit and<br />
explicit) type conversions, C# achieves better parity with the built-in types.<br />
Java C#<br />
ze="6.85"><br />
er bigNumber =<br />
igInteger("123456789012345678901234567890");<br />
<br />
BigInteger bigNumber =<br />
BigInteger.Parse("1234567890123456789012345<br />
er answer = bigNumber.multiply(new BigInteger("42")); var answer = bigNumber * 42;<br />
er square = bigNumber.multiply(bigNumber);<br />
var square = bigNumber * bigNumber;<br />
er sum = bigNumber.add(bigNumber);<br />
var sum = bigNumber + bigNumber;<br />
<br />
Built-in compound data types<br />
Both languages treat strings as (immutable) objects of reference type. In both languages the type contains a number<br />
of methods to manipulate strings, parse, format etc. In both languages regular expressions are considered an external<br />
feature and is implemented in separate classes.<br />
Both languages' libraries define classes for working with dates and calendars in different cultures. The Java<br />
java.util.Date is a mutable reference type where the C# System.DateTime is a struct value type. C# additionally<br />
define a TimeSpan type for working with time periods. Both languages support date/time arithmetic according to<br />
different cultures.<br />
Reference types<br />
Both languages use classes and interfaces as the primary means for defining new, object-oriented types. See below<br />
for further details.<br />
Value types<br />
C# allows the programmer to create user-defined value types, using the struct keyword. Unlike classes, and like the<br />
standard primitives, such value types are passed and assigned by value rather than by reference. They can also be<br />
part of an object (either as a field or boxed), or stored in an array, without the memory indirection that normally<br />
exists for class types.<br />
Because value types have no notion of a null value and can be used in arrays without initialization, they always come<br />
with an implicit default constructor that essentially fills the struct memory space with zeroes. The programmer can<br />
only define additional constructors with one or more arguments. Value types do not have virtual method tables, and<br />
because of that (and the fixed memory footprint), they are implicitly sealed. However, value types can (and