开发者

Method contains another method

开发者 https://www.devze.com 2023-01-07 01:32 出处:网络
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.

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

精彩评论

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