Improve C# compatibility (closes #715)