c# - What is the point of a static method in a non-static class? -


I have a problem understanding the underlying errors with the following code:

  class < Public Zero Print (String Mess) {Console.WriteLine (Mess); }} Class myOtherClass {public static zero print {string mess} {Console.WriteLine (dirt); }} Public stable class testing {public static zero main () {myClass MC = new myClass (); Mc.print ("hello"); MyOtherClass moc = new myOtherClass (); Moc.print ("vhhhat?"); // It says that I can not use static method in a steady state, but am I not? }}  

I can never think of a reason because no one will declare a static method in non-stable class, why not put an exception error in .NET.

In addition,

  moc.print ("vhhhat?");  

It says that I can not access the static method in non-static context, but the test and main are stable, what is the context?

  myOtherClass.print ("vhhhat?");  

This is not static, as you created an acceleration of a square named moc :

  myOtherClass moc = new myOtherClass ();  

Comments

Popular posts from this blog

email - PHP mail error ... failed to open stream : permission denied -

c# - ListView onScroll event -

c - Linux mmap() error -