开发者

Method contains another method

Can we 开发者_如何转开发use a method within an another method in C#


No that is not possible. The closest nested-like method is probably an anonymous method.
Example from msdn:

void StartThread()
{
    System.Threading.Thread t1 = new System.Threading.Thread
      (delegate()
            {
                System.Console.Write("Hello, ");
                System.Console.WriteLine("World!");
            });
    t1.Start();
}


You can use an anonymous delegate if you want a function with the lexical scope of your method.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜