Can an anonymous method in C# call itself?

前端 未结 6 1860
-上瘾入骨i
-上瘾入骨i 2020-12-08 02:03

I have the following code:

class myClass
{
private delegate string myDelegate(Object bj);

protected void method()
   {
   myDelegate build = delegate(Object         


        
6条回答
  •  执笔经年
    2020-12-08 02:26

    If you're creating a recursive function, I'd recommend avoiding anonymous delegates. Just create a method and have it call itself recursively.

    Anonymous methods are meant to be anonymous - you shouldn't be calling them by name (non-anonymously).

提交回复
热议问题