Hi
In this code, i can't reach public field m from the Main method. Why? It's public.
My other question is: why is this not allowed inside the Main method: public int n instead of just int n?
My last question is: why is this not allowed (without static): public void hello()?
Thanks
class Program
{
public int m;
static void Main(string[] args)
{
int n;
public int n; // no allowed
m = 5;//can't reach m
hello();
}
public static void hello()
{
Console.WriteLine("Hello, dit is mijn eerste method!");
}
}

Dharmesh SharmaRank #1,974 · 741 reputationPosted Jun 23, 2021, 5:09 AM EDT
Valerie MeunierRank #1,527 · 1K reputationPosted Jun 23, 2021, 5:24 AM EDT