C#: Function in Function possible?

前端 未结 7 950
面向向阳花
面向向阳花 2020-12-05 05:59

Is it possible to declare a method within another method in C#?

For example like that:

void OuterMethod()
{
    int anything = 1;
    InnerMethod();          


        
相关标签:
7条回答
  • 2020-12-05 06:56

    Five years have passed since this question was asked and now C# 7 is coming.

    It's slated to include local functions, and is apparently already implemented.

    Local functions (Proposal: #259) [currently in future branch]

    https://github.com/dotnet/roslyn/issues/259

    0 讨论(0)
提交回复
热议问题