Question
What is the point of a static method in a non-static class?
I have trouble understanding the underlying errors with the code below:
class myClass
{
public void print(string mess)
{
Console.WriteLine(mess);
}
}
class myOtherClass
{
public static void print(string mess)
{
Console.WriteLine(mess);
}
}
public static class Test
{
public static void Main()
{
myClass mc = new myClass();
mc.print("hello");
myOtherClass moc = new myOtherClass();
moc.print("vhhhat?");
//This says I can't access static method in non static context, but am I not?
}
}
I can't ever think of a reason why one would declare a static method in a non-static class, so why will .NET not throw an exception error.
Furthermore,
moc.print("vhhhat?");
This will say I can't access static method in non static context but Test and main are static, what is it referring to ?