T
Tom Baxter
Hi all,
Let's say I have this delegate:
delegate void MyDelegate<T1, T2>(T1 x, T2 y);
I can easily make an anonymous method of the above delegate type:
MyDelegate<int, float> md1 = delegate(int x, float y) {
Console.WriteLine("In the md);
};
If I do not need to reference the two parameters I can do this:
MyDelegate<int, float> md = delegate {
Console.WriteLine("In the md()");
};
My question is, can I create a lambda that will be equivalent to the
parameter-less anonymous method shown above? If I have no need to reference
the parameters, I don't want to. I tried the following two approaches,
neither or which work:
MyDelegate<int, float> md2 = () => {
Console.WriteLine("In the md()");
};
MyDelegate<int, float> md2 = => {
Console.WriteLine("In the md()");
};
Thanks very much.
Let's say I have this delegate:
delegate void MyDelegate<T1, T2>(T1 x, T2 y);
I can easily make an anonymous method of the above delegate type:
MyDelegate<int, float> md1 = delegate(int x, float y) {
Console.WriteLine("In the md);
};
If I do not need to reference the two parameters I can do this:
MyDelegate<int, float> md = delegate {
Console.WriteLine("In the md()");
};
My question is, can I create a lambda that will be equivalent to the
parameter-less anonymous method shown above? If I have no need to reference
the parameters, I don't want to. I tried the following two approaches,
neither or which work:
MyDelegate<int, float> md2 = () => {
Console.WriteLine("In the md()");
};
MyDelegate<int, float> md2 = => {
Console.WriteLine("In the md()");
};
Thanks very much.