Hi
this code works, but i have three questions:
1) why is static before void hello2() (wrong version of c#?)
2) Because method hello2() is non-static, how come it is called without instance?
3) what difference does it make between void hello2() and static void hello2() (asuming it's allowed)?
Thanks
using System;
class Oef1
{
static void hello()
{
string name = "Bob";
Console.WriteLine(name);
void hello2()
{
string vname = "Bill";
Console.WriteLine(vname);
}
hello2();
}
static void Main()
{ hello(); }
}

Naimish MakwanaRank #324 · 7.7K reputationPosted Jan 25, 2023, 4:57 AM EST
Hello Valerie
1) why is static before void hello2()
2) Because method hello2() is non-static, how come it is called without instance?
You can read more: https://www.geeksforgeeks.org/static-local-function-in-c-sharp-8-0/
3) what difference does it make between void hello2() and static void hello2().
You can read more: https://www.geeksforgeeks.org/static-local-function-in-c-sharp-8-0/
Thanks
Valerie MeunierRank #1,526 · 1K reputationPosted Jan 26, 2023, 3:49 AM EST
Thanks.