Below statement emit conditional statement
AddMethod(MemberAttributes.Public | MemberAttributes.Static, typeof(string), (int i)=>"Print",
   Emit.@if((int i)=>i < 10,
      Emit.@return(()=>"i less than 10")
   ),
   Emit.@return(()=>"i greater than or equals 10")
)
Generated code is as following
public static string Print(int i) {
    if ((i < 10)) {
        return "i less than 10";
    }
    return "i greater than or equals 10";
}

Last edited May 16, 2009 at 9:28 AM by AlexShirshov, version 3

Comments

No comments yet.