# 我可以使用带有params关键字的lambda表达式吗？(Can I use a lambda expression with params keyword?)

``` 可以说我有以下代码：
```delegate int MyDel (int n);   // my delegate

static int myMethod( MyDel lambda, int n) {
n *= n;
n = lambda(n);
return n;      // returns modified n
}
```
这样，具有不同的lambda表达式，我可以调整Method的输出。
```myMethod ( x => x + 1, 5);
myMethod ( x => x - 1, 5);
```
现在，如果我不想在lambda表达式中做任何aritmethic，我可以使用：
```myMethod ( x => x, 5);  // and lambda will simply return x
```
我的问题是，有没有办法使用lambda expresion和'params'可选属性？ 也许以某种方式将我的委托嵌入数组中？
``` static int myMethod (int n, params MyDel lambda) {
```Lets say I have the following code:
```delegate int MyDel (int n);   // my delegate

static int myMethod( MyDel lambda, int n) {
n *= n;
n = lambda(n);
return n;      // returns modified n
}
```
This way, having different lambda expression I can tune the output of the Method.
```myMethod ( x => x + 1, 5);
myMethod ( x => x - 1, 5);
```
Now, if I don't want to do any aritmethic in lambda expression, I could use:
```myMethod ( x => x, 5);  // and lambda will simply return x
```
My question is, is there a way to use the lambda expresion with 'params' optional properties? Maybe somehow embedding my delegate in array?
``` static int myMethod (int n, params MyDel lambda) {
```原文：https://stackoverflow.com/questions/3746476```

## 最满意答案

``` 这有用吗？
编辑对不起，用一只眼睛做这个，让我改一下。
```static int myMethod (int n, params  MyDel[] lambdas) {
```Does this work?
EDIT Sorry, was doing this with one eye, let me rephrase that.
```static int myMethod (int n, params  MyDel[] lambdas) {
``````
2010-09-19