C# version

Hi, 

I just did a straightforward conversion of the C++ code to C#. No attempt to optimize anything further.

The C# version is approximately 20% slower than the C++ one. 

Thanks,
Anastasios