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 MakwanaPosted Jan 25, 2023, 9:57 AM
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 MeunierPosted Jan 26, 2023, 8:49 AM
Thanks.