Below statement declares parameterless method Print with return value of type int and returns 100
AddMethod(MemberAttributes.Public | MemberAttributes.Static, typeof(int), ()=>"Print",
   Emit.@return(()=>100)
)
Another example
AddMethod(MemberAttributes.Public | MemberAttributes.Static, typeof(string), ()=>"Print",
   Emit.declare("guid", ()=>Guid.NewGuid()),
   Emit.@return((Guid guid)=>guid.ToString())
)
And here is what we get from CodeDOM
public static string Print() {
    System.Guid guid = System.Guid.NewGuid();
    return guid.ToString();
}

Last edited May 16, 2009 at 10:44 AM by AlexShirshov, version 7

Comments

No comments yet.