https://www.infoworld.com/article/3182416/c-7-in-depth-exploring-local-functions.html
I really need to know exactly following code how Local Functions supposed to be.
Am 0% IL Code/MSIL experience.
public static void Display(string str)
{
int ctr = 5;
DisplayText();
void DisplayText ()
{
for(int i = 0; i < ctr; i++)
Console.WriteLine(str);
}
}
Question I need to know here from previous code:
- If we call main function
Display()
does Local FunctionDisplayText()
always generated when main one called? Or it created as a fake local function in C# but in MSIL it generated as Global function? - In lamda expression method? does it same above?
- Is it safe to depend on local functions? or shall we not used it anyway. (performance maybe idk)
Edit:- I think Local Properties (which not exists yet or maybe ...). it is useful also sometimes. which you can have some calculation in same Method as a local property. as previous example but DisplayText are property. Wish they add it also.