Migrating Java to C# manually: four case studies
Migrate Java to C#: This paper discusses the basics in transitioning Java to C# code by hand. Learn more about the differences between C# versus Java through Java and C# code samples so you can migrate Java to C# applications.

by Jason A. Fletcher, application engineer, Intel Software and Solutions Group, Intel Corp.

This paper discusses the basics in transitioning Java code to C# code by hand. If you're afraid of looking at code, turn back now or abandon all hope. I present four simple examples to help you learn some of the basics of C#. I will not cover attributes or more advanced topics such as interoperability with ASP .NET, ADO .NET, and so forth. I also presume that you are familiar with the Visual Studio .NET environment from Microsoft. If you're not, refer to Appendix A for the concepts of VS that you'll need for these examples.

Before we get into the code samples, let's look briefly at some of the differences between Java and C#.

Surface language differences
Conventions

Java classes use Pascal notation. All other words (keywords, methods, variables, and so forth) use camel notation. Pascal notation uses initial caps for all words, such as ThisIsMyJavaClass. Camel notation is almost the same as Pascal, except the first word uses all lowercase letters, such as thisIsMyJavaMethod . C# is the nearly the inverse. Keywords and variables use camel notation, while all others (classes, exceptions, methods, and so forth) use Pascal notation.

Bracket placement when declaring arrays
In C#, place the brackets after the variable, like this: int[] array. Java can use the C# declaration or it can use int array[].

Properties
Properties in C# make class variable access more transparent to the user, as well as making the access look less like a method call. Depending on whether you want to get or set the value, the C# call will look like variable = Class.Property or Class.Property = value. Java implements the calls this way: variable = Class.getVariable() or Class.setVariable(value). Note that C# properties do not use parentheses.

Migration 1: bubblesort—arrays and indexers
Our first example is the bubblesort sorting algorithm. Before we proceed, create an empty project in VS and add a C# code file. Now, instead of explaining the simple algorithm, let's dive in:

Subscribers who liked this article also read:
Consolidating the IT infrastructure: leveraging Oracle9i Real Application Clusters on Intel to build an 'Adaptive Architecture'
Intel Corp., Oracle Corp., and Cap Gemini Ernst & Young. Cap Gemi...

If you're interested in this topic, these articles may be helpful:

Enterprise Java performance: best practices
by Kingsum Chow, Ricardo Morin, Kumar Shiv, Software and Solutions Gro...
Embedding .NET controls in Java
by Heath Stewart, Microsoft MVP, directory of technology, Proplanne...
Oracle JDeveloper 10g Handbook: Build Java 2 Platform, Enterprise Edition (J2EE) Applications
by Dr. Avram Roy-Faderman, Peter Koletzke, and Dr. Paul Dorsey. McGraw...
Java 1.4.1 for Mac OS X
from Apple Computer Inc. Java 2 Platform, Standard Editions 1.4.1...
Intel Itanium microarchitecture support for .NET and Java
by Matt Gillespie, technical author and editor. Intel Corp. The Int...

Related Jobs:

Senior Mediation Systems Developer #05-564-000904 - GA - Atlanta - EarthLink, Inc.
Senior Mediation Systems Developer 05-564-000904 posted 12/14/05 ...
Content Specialist #144557 - WA - Redmond - Microsoft Corporation
The User Experience (UX) group at Microsoft Game Studios (MGS) is seek...
Support Professional #151579 - WA - Issaquah - Microsoft Corporation
The role of a Support Engineer within the DSD group focuses on deliver...
Project Manager #53130161 - MT - Helena - MT StateGovt JOBS
Special Information: This Position is a grant-funded position with fu...
Programming Writer #151742 - WA - Redmond - Microsoft Corporation
Do you love XML? Do you love helping customers? Can't decide if you'd ...
Computer Programmer #52111896 - MT - Helena - MT StateGovt JOBS
pecial Information: The work is performed in controlled, comfortable ...
Security Architect #54561 - CA - Sacramento - EML Incorporated
Duration: 6 months The Security Architect will be responsible for c...
Technical Writer #149616 - WA - Redmond - Microsoft Corporation
Is your dream to write for cutting-edge video games in a world-class g...
Data Warehouse Engineer #05-562-000773 - CA - Pasadena - EarthLink, Inc.
Data Warehouse Engineer posted 11/09/05 Requirements D...
R&D Engineer, Staff #5641 - CA - Mountain View - Synopsys, Inc.
US01-Mountain View - R&D Engineering ----------------------------...