C++ and C# solution