C# Port

Simple translation.