C# re-write.