C# solution