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:

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

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

Related Jobs:

Network Management Tools Engineer - CA - Mountain View - Google
Google is looking for a highly experienced, tools-oriented Engineer to...
Security Architect #54561 - CA - Sacramento - EML Incorporated
Duration: 6 months The Security Architect will be responsible for c...
Enterprise Technology Architect - Security #05285-3 - OR - Portland - StanCorp Financial Group, Inc.
Job Title Enterprise Technology Architect - Security Requisitio...
Configuration Management Engineer - OH - Cincinnati - Professional Data Resources, Inc.
This Position's Key Responsibilities Include: Identify, control, an...
R&D Engineer, Staff #5641 - CA - Mountain View - Synopsys, Inc.
US01-Mountain View - R&D Engineering ----------------------------...
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...
Technical Writer #149616 - WA - Redmond - Microsoft Corporation
Is your dream to write for cutting-edge video games in a world-class g...
Project Manager #53130161 - MT - Helena - MT StateGovt JOBS
Special Information: This Position is a grant-funded position with fu...
Programming Writer #132618 - WA - Redmond - Microsoft Corporation
Do you like to program? Do you like to write? Are you excited by Inter...