Previous Topic Next topic Print topic


Program Structure - in COBOL and C#

Program Structure in Managed COBOL

class-id HelloWorld as "Hello.Helloworld".

method-id main static.
local-storage section.
01 helloString string value "COBOL".
procedure division using by value args as string occurs any.

    if length of args > 0
        set helloString to args(1)
    end-if
    display "Hello, " & helloString & "!"

end method.

end class. 

Program Structure in C#

namespace Hello
{
    public class HelloWorld
    {
        public static void Main(string[] args)
        {
            string helloString = "C#";

            if (args.Length > 1)
            {
                helloString = args[0];
            }
            System.Console.WriteLine("Hello, " + helloString + "!");
        }
    }
}
Previous Topic Next topic Print topic