Lecture overview -- Keyboard shortcut: 'u'  Previous page: Control structures for iteration -- Keyboard shortcut: 'p'  Next page: Arrays -- Keyboard shortcut: 'n'  Lecture notes - all slides and notes together  slide -- Keyboard shortcut: 't'  Textbook -- Keyboard shortcut: 'v'  Help page about these notes  Alphabetic index  Course home  Page 34 : 43
Object-oriented Programming in C#
Introduction to C#
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

A Visual Basic Program with an array of 10 elements.

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]);
  }
}

The similar C# program with an array of 10 elements.