Created
January 23, 2020 13:11
-
-
Save Mozart-Alkhateeb/cc53b39db28e9ed10d498e4fc5bdfc45 to your computer and use it in GitHub Desktop.
Local Functions Example C#
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
namespace ConsoleApp1 | |
{ | |
class Program | |
{ | |
static void Main(string[] args) | |
{ | |
//This function has access Only to its direct children [MakeTextUpperCase, GetName] | |
Console.WriteLine(GetName()); | |
string MakeTextUpperCase(string x) | |
{ | |
return x.ToUpper(); | |
} | |
string GetName() | |
{ | |
return MakeTextUpperCase($"{GetFirstName()} {GetLastName()}"); | |
string GetFirstName() | |
{ | |
return "Mozart"; | |
} | |
string GetLastName() | |
{ | |
return "Al Khateeb"; | |
} | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment