34
1
using System;
2
using System.Linq;
3
using System.Linq.Expressions;
4
5
public class Program
6
{
7
public class SubClass
8
{
9
public void MyMethod(string name, int value)
10
{
11
12
}
13
}
14
15
public static void Main(string[] args)
16
{
17
Console.WriteLine(
18
MethodProcessor.CreateStringForCall<SubClass>(
19
(o)=>o.MyMethod("theName",4)));
20
}
21
22
}
23
24
class MethodProcessor
25
{
26
public static string CreateStringForCall<T>(Expression<Action<T>> methodCall)
27
{
28
var exp = methodCall.Body as MethodCallExpression;
29
var retVal = string.Concat(exp.Method.Name, "/",
30
string.Join("/", exp.Arguments.Cast<ConstantExpression>().Select(a => a.Value.ToString())));
31
return retVal;
32
}
33
}
34
Cached Result
Achou o valor: Valor de A