Thursday, August 27, 2009

C# tutorial for VB programmers

I've been doing some C# programming lately. I came across some difference from VB.net

Random Values:
ushort x1 = 0;
Random r = new Random();
x1=(ushort)r.Next(0,5);
will give a number between 0 and 5 in x1.

Typecasting:
In the example above r will return a int, to convert it to ushort add (ushort) before.

Passing Optional variables:
C# doesn't support Optional variables.
VB code:
Sub MySub(x as integer, Optional n as integer=33)
' n will be 33 if not set when sub is called.
End Sub
In C# this isn't supported, you will have to Overload the sub instead( = more code).



To get help convtering VB -> C# or C# -> VB there is a good site www.developerfusion.com/tools/convert/vb-to-csharp/

Or you can write you code using SharpDevelopment to convert between VB, C# and Boo.

MySQL to MariaDB

 Here is a good description how to migrate to MariaDb MySQL to MariaDb Example of how to dump data from MySQL port=3307: mysqldump --user=ro...