Today I delved into the world of C# and I have to honestly say it felt like I had once visited this particular world before. Having a background in Java made using C# seem familiar but not quite. There were many times where my assumptions were proven correctly. For example, when going through the Roman Numerals kata, in order to generalised the following code.

if (num == 2) {
return "II";
}
return "I";

I figured in Java I would most likely use a mutable string that I could then easily then append to. I thought to myself, "I wonder if C# has a class like StringBuilder", lo and behold... it does !! and it's called "StringBuilder".

The similarities don't stop there, here are class declarations in Java and C#

  public class RomanNumerals
public class RomanNumerals

okay that's not a typo, class declarations are identical.
Or how about method declarations?

  public static string convert (int arabic)
public static String convert(int arabic)

again... no typo but there's a difference... the method declaration at the top is C#, the bottom declaration is Java. So the difference is the "String" text, one being uppercase and the other lowercase.

Seeing little difference between the two languages, I decided to go full steam ahead with assumptions and so far I have only hit a few roadblocks, most of which were to do with the two languages have a different keyword for a similar functionality. e.g. "using" in C# and "import" in Java.

Which language do I prefer? too little of a difference to tell at the moment, perhaps once I complete the Tic tac toe project in C#, I'll be in a better position to give a well formed opinion.

 

Ced