Main Function

Let's look at a simple program written in C# that performs the same action as our first sample: It displays the single line “Hello from C#.” (If you don't know C#, you can refer to Appendix B, “C# Survival Guide for PerlNET Programmers.”) We saved the program in the HelloCs folder.

// Hello.cs
using System;

class Hello
{
   public static void Main(string[] args)
   {
      Console.WriteLine("Hello from C#");
   }
}

As you can see, we defined a class with a single static method Main, and this is the minimum requirement of each .NET program.

Unlike C# or other .NET-compliant languages, in PerlNET you are not required explicitly to define the Main function and wrap your program by the class, which means that our PerlNET programs may be written ...

Get Programming PERL in the .NET Environment now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.