c# - Using a lambda expression to specify parameter of method -


given methodinfo of method how can use lambda expression specify parameter (parameterinfo)?

for example, given following method signature:

public string dosomething(int id, int count); 

i have method:

withparameter(methodinfo info, expression<???> expression); 

which invoked so:

withparameter(dosomethingmethodinfo, x => x.id)  

is possible?

if want specify parameter name in statically safe way, not possible.
2 reasons:

  1. c# not support parameters
  2. methodinfo had lost static type information

alternative approaches different depending on final goal.


Comments

Popular posts from this blog

user interface - Python attempting to create a simple gui, getting "AttributeError: 'MainMenu' object has no attribute 'intro_screen'" -

jquery - Common JavaScript snippet to share files on Google Drive, Dropbox, Box.net or SkyDrive -

Android Gson.fromJson error -