Back to Basics

Previously my only programming experiance was in Delphi’s Object Pascal. Now I also have Delphi’s Prism for mono which is C# and is basically equal to the free MonoDevelopment package, as well as Delphi’s Prism in Visual Studio 2010 which allows the use of the Oxygene language from RemObjects which is a hybrid Object Pascal editor resulting in what I’m pretty sure is C# NET code. As your application requires C# and I have to either learn that language or use the RemObjects VS 2010 solution, can anyone help me with making the right choice to begin with? Any replies will be greatly appreaciated!


Thanx for the great info! I did not expect so much. But you did not say which compiler/DIE you use. I guess Mono 3.0 or Visual Studio Express 2010 for C# are the only choices I have unless Unity comes with its own. Does it?

I started myself with Pascal (17 years ago) and moved then to Delphi (around 2000). I never heard of prism or oxygen yet. Sounds interesting but it’s not suitable for Unity. While it’s possible to create .NET assemblies in any .NET language it’s a horrible workflow since you can’t test immediately in Unity. You need always to create an assembly and copy it into the Unity project.

I recommend learning C#. It seems you’re already a skilled programmer so it shouldn’t be that hard to switch. Have you any experience with a C-style language (C, C++, Javascript, …)? That would simplify the language change. What i found the most irritating when i learned C++ (my switch away from Delphi) was the operator syntax. However most languages that are based on C syntax have the same or almost the same set of operators.

A quick overview:

operator              Delphi    C#
assignment            :=        =
equally               =         ==
inequally             <>        !=
logical NOT           not       !
logical AND           and       &&
logical OR            or        ||
bitshift left         shl       <<
bitshift right        shr       >>
bitwise AND           and       &
bitwise OR            or        |
bitwise XOR           xor       ^
bitwise NOT           not       ~
increment             inc(x)    x++    or  ++x
decrement             dec(x)    x--    or  x--

In C# there are some more operators. For most operators there are combined operators available:

combined              equals
x += 5                x = x + 5
x >>= 2               x = x >> 2

Another difference is that each statement has also a return type of some kind. Even an assignment has as expression value the value that has been assigned. That’s why those things are possible:

x = y = 5;
Y = x++;

There are two kinds of increment operators, pre and post increment. As the name says one is executed before the expression value is evaluated the other afterwards.

int x = 5;
y = x++;    // y will be 5 x will be 6
y = ++x;    // y and x will be 7

Variable declarations look like this:

[access modifier][static] TYPE NAME [= INITVALUE];

== optional

C# also supports the var keyword which allows you to omit the type. However when you use it you have to assign an init value to it. This way the compiler can determine the type. This is called type inference.

var i = 0;   // will be an int-variable

There’s actually no difference beteen a function or a procedure. a procedure just have as return type “void”.

void MyProcedure()
    // do something

Calling a function always requires the brackets:


Returning a value from a function is only possible with the return statement:

int MyFunction(int a, int b)
    return a + b;

In C# you can’t declare global functions or variables. This is only possible in a class.

That should be enough to get started :wink: Well there’s a lot more i could talk about but i’m tired now :smiley: