Previous Topic Next topic Print topic


Program Structure - in COBOL and C# and VB.NET

C# COBOL VB.NET
using System;

namespace Hello
{
   public class HelloWorld
   {
      public static void Main(string[] args)
      {
         string name = "C#";
         // See if an argument was passed from the command line
         if (args.Length == 1)
         {
            name = args[0];
         }
         Console.WriteLine("Hello, " + name + "!");
      }
   }
}
class-id MicroFocus.Examples.HelloWorld.
*> member variable
01 field1           binary-long. 

method-id Main static(args as string occurs any).
    declare nam as string = "Bob"
    *> See if an argument was passed from the command line
    if size of args > 0
        set nam to args[0] *> [] means 0 based index
    end-if
end method.

end class.
Imports System
   Namespace Hello
   Class HelloWorld
      Overloads Shared Sub Main(ByVal args() As String)
         Dim name As String = "VB.NET"
         'See if an argument was passed from the command line
         If args.Length = 1 Then
            name = args(0)
         End If
         Console.WriteLine("Hello, " & name & "!")
      End Sub
   End Class
   End Namespace
End Class
Previous Topic Next topic Print topic