generate C# for closure