Wednesday, April 13, 2005

C# and his big brother

Lately I have been doing my first (real world) C# project. (Unfortunately I had to do it in VS2003 ;( )
C# must be Delphi's little brother! The language really feels like the Delphi language. Also the syntax, was not all that difficult to get used to.
I find my self programming 'Delphi code style' in C#.

For example in Delphi you write a function like this:

function ReturnANumber(SomeCondition : Integer) : Integer;
begin
Result := 0;
If SomeCondition > 100 then
Result := 101
else
Result := 102;
end;

You can not do this in C#, because it will return immediately to the caller, so I figured the following:

private int ReturnANumber(int SomeCondition)
{
int Result;
Result = 0;
If (SomeCondition > 100)
{
Result = 101

}
else
Result = 102;

return Result;
}

How about this function:

private void bool Assigned(object AObject)
{
if (AObject = null) return false else return true;
}

If you use this function for raising an event, well it could almost be Delphi :-)

if Assigned(SomeMethodPointerType) SomeMethodPointerType(this);

No comments:

Use an image as your UIBarButtonItem

Using an image as your UIBarButtonItem in your navigationcontroller bar can only be achieved by using a common UIButton as the BarButtonItem...