Shared C# utility code