public
delegate
void
del();
del d
=
Func;
d.Invoke();
public
static
void
Func()
{
Console.WriteLine(
"
i am delegate
"
);
}
//
无返回值
Action<
string
> a1 =
delegate
(
string
a) { Console.WriteLine(
"
I am action :{0}
"
, a); };
Action
<
string
> a2 = (a => { Console.WriteLine(
"
I am action :{0}
"
,a); });
a1.Invoke(
""
);
//
有返回值
Func<
string
> f = () => {
return
""
; };
Func
<
string
,
string
> f1 = a => {
return
a; };
string
re =
f.Invoke();
string
re1 = f1.Invoke(
""
);
//
返回bool
Predicate<
int
> pr = a =>
{
if
(a %
2
==
0
)
{
return
true
; }
else
{
return
false
; }
};

