Can i access a method from a instance of the class? Example:
class myClass
{
private static int n = 0;
public static myClass()
{ n = 5;}
public static void Afis()
{
Console.WriteLine(n);
}
}
and in the void Main:
static void Main()
{
myClass m = new myClass();
m.Afis();
}
This gives me: cannon be accessed with an instance referece
. Is it because i declared the function static? If that is so when should I use static and when not because in c++ if i declare something with static it just initialize once. Is that the case with c#?