CSharp optimization