Class declaration with one public method. : public « Class Interface « C# / C Sharp






Class declaration with one public method.



using System;

public class MyClass
{
   public void DisplayMessage()
   {
      Console.WriteLine( "Welcome to the Grade Book!" );
   }
} 

public class MyClassTest
{
   public static void Main( string[] args )
   {
      MyClass myMyClass = new MyClass();
      myMyClass.DisplayMessage();
   }
}

           
       








Related examples in the same category

1.Class declaration with a public method that has a parameter.
2.MyClass class with a public constructor to initialize the course name.
3.A public constructor initializes private instance variable balance through public property.
4.User-defined public method