This link has been bookmarked by 263 people . It was first bookmarked on 23 May 2006, by yw.
-
19 Oct 16
-
12 Nov 14
-
goto (no longer considered harmful)
-
-
14 Apr 14
-
31 Mar 14
-
01 Dec 13
-
# PROGRAMMING LANGUAGE
TO SUN MICROSYSTEMS' JAVA P
-
-
12 Oct 13
-
25 Sep 13
-
sealed
-
final
-
-
09 Sep 13
Konstantinos"A Comparison Of Microsoft's C# Programming Language
To Sun Microsystems' Java Programming Language"
By Dare Obasanjo -
25 Feb 13
-
02 Oct 12
-
16 Mar 12
-
10 Jan 12
-
08 Jan 12
-
07 Dec 11
-
20 May 11
vikramsjn"A COMPARISON OF
MICROSOFT'S C# PROGRAMMING LANGUAGE
TO SUN MICROSYSTEMS' JAVA PROGRAMMING LANGUAGE
By
Dare Obasanjo" -
07 May 11
-
05 May 11
-
the
Mainmethod in C# begins with an uppercase "M" (as do all .NET Framework method names, by convention) -
in .NET naming conventions, interface names have an upper-case "I" prepended to their names (as in IClonable)
-
Pass by Reference
-
The
yieldkeyword enables one to convert any method or property into an iterator. -
The
??operator is called the null coalescing operator and is used for testing the value of a nullable type and returning its value or an alternate if its value is null.
-
-
08 Mar 11
-
16 Jan 11
-
20 Nov 10
-
We Are All Objects
-
Just like Java, C# has a single rooted class hierarchy where all classes in C# are subclasses of
System.Object -
NOTE: In C#, the object class can either be written as
objector Object. The lower case "object" is a C# keyword which is replaced with the class name "System.Object" during compilation. -
extern
native
-
operator
N/A
-
as
N/A
-
out
N/A
-
override
N/A
-
base
super
-
bool
boolean
-
params
...
-
typeof
N/A
-
fixed
N/A
-
uint
N/A
-
partial
N/A
-
ulong
N/A
-
byte
N/A
-
foreach
for
-
protected
N/A
-
unchecked
N/A
-
unsafe
N/A
-
get
N/A
-
readonly
N/A
-
ushort
N/A
-
using
import
-
ref
N/A
-
checked
N/A
-
implicit
N/A
-
value
N/A
-
virtual
N/A
-
in
N/A
-
sbyte
byte
-
sealed
final
-
decimal
N/A
-
set
N/A
-
where
extends
-
internal
protected
-
delegate
N/A
-
sizeof
N/A
-
is
instanceof
-
lock
synchronized
-
stackalloc
N/A
-
yield
N/A
-
:
extends
-
string
N/A
-
namespace
package
-
:
implements
-
struct
N/A
-
enum
N/A
-
event
N/A
-
object
N/A
-
explicit
N/A
-
Heap Based Classes
-
In Java objects are created on the heap using the
newkeyword. Most classes in C# are created on the heap by using thenewkeyword. -
NOTE: C# also supports stack-based classes, called value types, which are discussed further below.
-
Arrays Can Be Jagged
-
In Java and C# arrays do not have to be uniform because jagged arrays can be created as one-dimensional arrays of arrays.
-
In a jagged array the contents of the array are arrays which may hold instances of a type or references to other arrays.
-
int [][]myArray = new int[2][]; myArray[0] = new int[3]; myArray[1] = new int[9];
-
No Global Methods
-
Just like Java and unlike C++, methods in C# have to be part of a class either as member or static methods.
-
Interfaces, Yes. Multiple Inheritance, No
-
Strings Are Immutable
-
Both classes are immutable meaning that the values of the strings cannot be changed once the strings have been created.
-
In both instances methods that appear to modify the actual content of a string actually create a new string to return, leaving the original string unchanged. Thus the following C# and Java code does not modify the string in either case
-
csString.ToLower(); /* Does not modify string, instead returns lower case copy of string */
-
jString.toLowerCase(); /* Does not modify string, instead returns lower case copy of string */
-
To create a string-like object that allows modification in C# it is advisable to use the System.Text.StringBuilder
-
In C#, the string class can either be written as
stringor String. -
Unextendable Classes
-
Both Java and C# provide mechanisms to specify that a class should be the last one in an inheritance hierarchy and cannot be used as a base class. In Java this is done by preceding the class declaration with the
finalkeyword while in C# this is done by preceding the class declaration with thesealedkeyword. -
sealed
-
final
-
Throwing and Catching Exceptions
-
the catch block for handling thrown exceptions
-
finally block for releasing resources before leaving the method.
-
have an inheritance hierarchy where all exceptions are derived from a single Exception class.
-
C# Code
-
: Exception
-
: base(message)
-
: base(message, innerException)
-
throw
-
}catch(
-
finally{
-
Java Code
-
MyException
-
extends Exception
-
super(message);
-
super(message, innerException);
-
MyException
-
throws Exception
-
finally{
-
Main Method
-
In C# one can get the same effect by compiling the application with the /main switch to specify which main should be used as the starting point of the application when the executable is created
-
/out:
-
/main:
-
However, On the other hand, Java doesn't support conditional compilation, so the main method will be part of even your released classes.
-
Inheritance Syntax
-
implements -
extends -
class B:A, IComparable{
-
implements
-
extends
-
Although it should be noted that in .NET naming conventions, interface names have an upper-case "I" prepended to their names (as in IClonable)
-
Run Time Type Identification (is operator)
-
C# Code
-
(x is MyClass)
-
Java Code
-
instanceof
-
n Java, the package names dictate the directory structure of source files in an application
-
in C# namespaces do not dictate the physical layout of source files in directories only their logical structure.
-
namespace
-
package
-
C#
namespacesyntax also allows one to nest namespaces in the following wayC# Code -
namespace Company{
-
namespace Carnage4life{
-
}// namespace Carnage4life }// namespace Company
-
Finalizers
-
Destructors
-
Constructors
-
Synchronizing
-
Code Blocks
-
Access Modifiers
-
protected
-
internal
-
protected
-
internal protected
-
Reflection
-
Declaring Constants
-
Primitive Types
-
Array Declarations
-
Calling Base Class Constructors and Constructor Chaining
-
: this
-
: this
-
: base
-
Variable Length Parameter Lists
-
Generics
-
for-each Loop
-
Metadata Annotations
-
Enumerations
-
public enum
-
Nested classes
-
private class Engine
-
private static class Engine{
-
Threads and Volatile Members
-
Operator Overloading
-
override
-
switch Statment
-
goto (no longer considered harmful)
-
Virtual Methods (and final ones too)
-
File I/O
-
Multiple Classes in a Single File
-
C# does not have a restriction on the number of public classes that can exist in a source file and neither is there a requirement for the name of any of the classes in the file to match that of the source file.
-
Importing Libraries
-
must be referenced somewhere in the source file
-
via the
usingkeyword in C# -
Using libraries in an application is a two-step process
-
where to find the location of the needed library
-
Delegates
-
functors in C++
-
Delegates are a mechanism for providing callback functions
-
Delegates are akin to function pointers in C
-
Value Types (Structs)
-
struct
-
Properties
-
A property is accessed by users of a class as if it was a field or member variable but in actuality is a method call
-
Properties are a way to abstract away from directly accessing the members of a class,
-
similar to how accessors (getters) and modifiers (setters) are used in the Java world
-
It is possible to create, read-only, write-only or read-write properties depending on if the getter and setter are implemented or not
-
//property with public getter and private setter public string Name{ get{ return name; } private set { name = value; } }
-
//read-write property for class member, minimum_age
-
The use of properties as an abstraction away from whether a member access is a method call or not may fall apart if the property throws an exception.
-
Multidimensional Arrays
-
int[,]
-
Aliases
-
using Terminal = System.Console;
-
Pointers and Unsafe Code
-
Although core C# is like Java in that there is no access to a pointer type that is analogous to pointer types in C and C++, it is possible to have pointer types if the C# code is executing in an
unsafecontext. When C# code is executing in an unsafe context, a lot of runtime checking is disabled which means that the program must have full trust on the machine it is running on -
Pass by Reference
-
In Java the arguments to a method are passed by value meaning that a method operates on copies of the items passed to it instead of on the actual item
-
In C#, as in C++ and in a sense C, it is possible to specify that the arguments to a method actually be references to the items being passed to the method instead of copies.
-
This feature is particularly useful when one wants to create a method that returns more than one object. In Java trying to return multiple values from a method is not supported
-
The C# keywords used to specify that a parameter is being passed by reference are
refandout -
The difference between the keywords is that parameters passed using
refmust be initialized to some value while those passed usingoutdo not have to be. -
out string
-
ref int
-
ref int
-
, ref
-
Swap(ref
-
(out s);
-
Verbatim Strings
-
Thus backslashes, tabs, quotes and newlines can be part of a string without using escape sequences.
-
avoid the usage of escape sequences within string constants and instead declare strings literally
-
Verbatim strings are specified by prepending the
@symbol to string declarations. -
double quotes that appear within verbatim strings should be doubled
-
caveat
-
//verbatim string
-
string filename = @"
-
//regular string
-
string filename2 =
-
Overflow Detection
-
Explicit Interface Implementation
-
Iterators (Continuations)
-
Partial Types
-
Static Classes
-
no instance constructors
-
cannot be used as a base class
-
A static class should be used to define types for which instances don't make sense such as the
System.EnvironmentandSystem.Mathclasses. -
A static class is a class that has no instance members
-
Nullable Types
-
A nullable types is an instance of the
System.Nullabletype. A nullable type can represent the normal range of values for an underlying value type as well as thenullvalue. For example, the typeNullable<bool>can represent the valuestrue,falseandnull -
A nullable type can be declared by appending the operator '?' to the name of a value type when declaring the variable. This means that
bool?is equivalent toNullable<bool>. Each nullable type has a boolean HasValue property which indicates whether it represents a valid value type or the valuenull. -
Anonymous Methods
-
Dynamic Class Loading
The ability to dynamically load classes at runtime in Java is a very powerful feature especially when combined with a remote procedure call mechanism. Dynamic class loading enables Java applications to download the class files (i.e. byte codes) of classes that do not exist on the target machine. An object type that only exists on one machine can be transferred to other machines in a seamless and transparent manne
-
-
04 Nov 10
-
06 Oct 10
-
30 Sep 10
-
28 Aug 10
-
28 Jul 10
-
02 Jul 10
-
21 Jun 10
-
20 May 10
-
17 Mar 10
-
18 Feb 10
-
09 Feb 10
Dhruv Sengupta"xceptions in C# and Java share a lot of similarities. Both languages support the use of the try block for indicating guarded regions, the catch block for handling thrown exceptions and the finally block for releasing resources before leaving the method. Both languages have an inheritance hierarchy where all exceptions are derived from a single Exception class. Exceptions can be caught and rethrown after some error handling occurs in both languages. Finally, both languages provide a mechanism for wrapping exceptions in one another for cases where a different exception is rethrown from the one that was caught. An example of using the exception wrapping capability is a three tier application where a SQLException is thrown during database access but is caught, examined, then an application specific exception is thrown. In this scenario the application specific exception can be initialized with the original SQLException so handlers of the application specific exception can access the original exception thrown if needed. Below are two equivalent code samples that show the similarities between exceptions in both languages.
NOTE: Although exceptions in both languages support methods for getting a stack trace, only Java exceptions have methods that allow one to alter the stack trac" -
03 Feb 10
-
02 Jan 10
-
30 Dec 09
-
03 Dec 09
-
18 Nov 09
-
17 Nov 09
-
30 Oct 09
-
19 Oct 09
golimpioIntroduction
The C# language is an object-oriented language that is aimed at enabling programmers to quickly build a wide range of applications for the Microsoft .NET platform. The goal of C# and the .NET platform is to shorten development time by freein -
18 Oct 09
-
15 Oct 09
-
13 Oct 09
-
11 Sep 09
-
C# has a ParameterInfo class which contains metadata about the parameters of a Method while Java uses Class objects for that which lose some information such as the name of the parameter
-
in C# the
constkeyword is used for compile time constants while thereadonlykeyword is used for runtime constants
-
-
05 Sep 09
-
16 Jul 09
-
29 Jun 09
-
24 Jun 09
-
26 May 09
-
14 May 09
-
20 Apr 09
-
18 Apr 09
-
11 Apr 09
-
04 Apr 09
-
03 Feb 09
-
26 Jan 09
-
21 Jan 09
-
18 Oct 08
-
09 Oct 08
-
06 Oct 08
clementi1832A COMPARISON OF
MICROSOFT'S C# PROGRAMMING LANGUAGE
TO SUN MICROSYSTEMS' JAVA PROGRAMMING LANGUAGE -
03 Oct 08
-
25 Sep 08
-
23 Sep 08
-
16 Sep 08
-
12 Sep 08
-
05 Aug 08
Gabor NagypalCOMPARISON OF MICROSOFT'S C# PROGRAMMING LANGUAGE TO SUN MICROSYSTEMS' JAVA PROGRAMMING LANGUAGE
-
04 Aug 08
-
03 Aug 08
-
12 Jul 08
-
08 Jul 08
-
16 Jun 08
-
03 Apr 08
-
27 Mar 08
-
15 Mar 08
-
27 Feb 08
-
21 Feb 08
Pablo Lima DiasAn overview of similarities and differences between the language features and libraries of the C# and Java programming languages.
-
11 Feb 08
-
18 Jan 08
-
04 Dec 07
-
16 Nov 07
-
07 Nov 07
-
30 Oct 07
-
04 Oct 07
Slobodan PavkovA COMPARISON OF
MICROSOFT'S C# PROGRAMMING LANGUAGE
TO SUN MICROSYSTEMS' JAVA PROGRAMMING LANGUAGEc# .net java sun comparison article programming importedfromdelicious
-
01 Oct 07
-
29 Sep 07
-
04 Aug 07
-
29 Jul 07
-
The C# language is an object-oriented language that is aimed at enabling programmers to quickly build a wide range of applications for the Microsoft .NET platform. The goal of C# and the .NET platform is to shorten development time by freeing the developer from worrying about several low level plumbing issues such as memory management, type safety issues, building low level libraries, array boundschecking , etc. thus allowing developers to actually spend their time and energy working on their application and business logic instead. As a Java developer the previous sentence could be described as "a short description of the Java language and platform" if the words C# and the .NET platform were replaced with words Java and the Java platform.
-
-
17 Jul 07
-
28 Jun 07
-
22 Jun 07
-
25 May 07
-
20 May 07
-
14 May 07
Page Comments
Venham conferir o AS NOVIDADES DO SERVIDOR de MU online JOGANDO.NET : www.jogando.net/mu
NÃO PERCA O novo site de Animes Cloud : http://www.animescloud.com/ com mais de 20.000 videos online.
Curta também a nossa pagina no facebook : http://www.facebook.com/pages/jogandonet/371027529618526
1ª Mega Maratona Jogando.net eventos diarios e novidades em todos os servidores atualizados p/ o Ep 3 Season 6 com novos kits DEVASTATOR , e o SUPREMO DIAMOND v2.
By: MissDeath
Would you like to comment?
Join Diigo for a free account, or sign in if you are already a member.