Lecture overview -- Keyboard shortcut: 'u'  Previous page: Control structures for iteration -- Keyboard shortcut: 'p'  Next page: Arrays -- Keyboard shortcut: 'n'  Lecture notes - all slides together  Annotated slide -- Keyboard shortcut: 't'  Textbook -- Keyboard shortcut: 'v'  Alphabetic index  Help page about these notes  Course home    Introduction to C# - slide 34 : 43

Arrays
Option Strict On
Option Explicit On
Module ArrayDemo

    Sub Main()
      Dim table(9) as Integer  ' indexing from 0 to 9. 

      For i as Integer = 0 To 9
        table(i) = i * i
      Next

      For i as Integer = 0 To 9
        Console.WriteLine(table(i))
      Next

    End Sub
End Module
using System;

class ArrayDemo{

  public static void Main(){
    int[] table = new int[10];  // indexing from 0 to 9

    for(int i = 0; i <= 9; i++)
      table[i] = i * i;

    for(int i = 0; i <= 9; i++)
      Console.WriteLine(table[i]);
  }
}