C# language feature:

  • Local functions

applies to

  • methods/code blocks

benefit

  • Allow declaration of helper functions where used.

how to use

  • Declare and use a method within a code block.

example:

        void Local_Functions_Example()
        {
            Display("Hi");
            Display("How are you?");

            void Display(string somestring) => System.Console.WriteLine(somestring);
        }