C# implementation