Using command-line arguments to initialize an array.

using System;

public class InitArray
{
public static void Main( string[] args )
{
int arrayLength = Convert.ToInt32( args[ 0 ] );
int[] array = new int[ arrayLength ]; // create array

int initialValue = Convert.ToInt32( args[ 1 ] );
int increment = Convert.ToInt32( args[ 2 ] );

for ( int counter = 0; counter < array.Length; counter++ ) array[ counter ] = initialValue + increment * counter; Console.WriteLine( "{0}{1,8}", "Index", "Value" ); for ( int counter = 0; counter < array.Length; counter++ ) Console.WriteLine( "{0,5}{1,8}", counter, array[ counter ] ); } } [/csharp]

Static Main function


   

/*
Learning C# 
by Jesse Liberty

Publisher: O&#039;Reilly 
ISBN: 0596003765
*/
 using System;
 namespace StaticTester
 {
     // create the class
    public class StaticTester
    {
       // Run is an instance method
       public void Run()
       {
           Console.WriteLine("Hello world");
       }

       // Main is static
       static void Main()
       {
           // create an instance
           StaticTester t = new StaticTester();

           // invoke the instance method
           t.Run();
       }
    }
 }