.NET Lambda Pass Method Parameter
        Posted  
        
            by RM
        on Stack Overflow
        
        See other posts from Stack Overflow
        
            or by RM
        
        
        
        Published on 2010-05-31T02:18:35Z
        Indexed on 
            2010/05/31
            2:22 UTC
        
        
        Read the original article
        Hit count: 441
        
Hi All,
I hope i'm missing something obvious, but I'm having some troubles defining a method that takes a parameter of a method to fetch the method information for the passed method. I do NOT want actually execute the method.
I want to be able to do:
  busObject.SetResolverMethod<ISomeInterface>(x=>x.GetNameById);
Where GetNameById is a method defined on the interface ISomeInterface. In this case, an example of the method being passed in's signature would be:
 MyVarA GetNameById(int id){ .... }
In the above example, the SetResolverMethod's body should be able to return / store the string "GetNameById".
There is no standard signature the method being passed in will conform to (except that it will always return an object of some kind).
Currently I'm setting the method as a string (i.e. "GetNameById"), but I want it to be compile time checked, hence this question.
© Stack Overflow or respective owner