C# for Java Programmers

The Java and C# string classes are very similar. In many instances the only difference between a member of the Java string class java.lang.string and the C# class System.String is in the capitalization of the method name. Another interesting tidbit is that both System.String and the datatype string can be used interchangeably. The reason for this is that Microsoft has aliased the string datatype to the System.String class. Most of the Java string methods are included in the C# string class, as well as some other methods, courtesy of Perl and Visual Basic. We will go over String creation, and then proceed into the StringBuilder class, which is very much like Java s StringBuffer. We will then discuss the RegEx class, which permits use of Regular Expressions, a very powerful feature that was Perl s claim to fame. Regular Expressions are not yet available in the Java SDK 1.3. However, Sun is planning to include it in the next release of the Java SDK.
C# s System.WriteLine method is the counterpart to Java s console output method System.out.println() . Here is a simple application that prints to the console in both languages so you can observe the similarities.
public class PrintExample { public static void main(String[] args) {<a name="276"></a><a name="beginpage.EEA1B83C-1D56-4D71-B8C2-164357C8BB59"></a> <b class="bold">System.out.println</b>("Hello Bruce!"); }} class PrintExample { public static void Main(string[] args) { <b class="bold">System.Console.WriteLine</b>("Hello Bruce!"); }} This function has...