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.
精彩评论