Home > Programme Index

Chapter 11 Extras.

Hint

I'm interested to know how this particular example can be done just using the manual as a reference - answers on a postcard.....

The answer is just a modification of an example from Karli Watson's book "Beginning Visual C#". If you don't have the book, here is the example:

This program displays on the console the string in displayString one letter at a time.

using System;
using System.Timers;

namespace Ch12Ex01
{

class Class1
{

static int counter = 0;

static string displayString = "This string will appear one letter at a time. ";

[STAThread]
static void Main(string[] args)
{

Timer myTimer = new Timer(100);
myTimer.Elapsed +=
new ElapsedEventHandler(WriteChar);
myTimer.Start();
Console.ReadLine();

}

static void WriteChar (object source, ElapsedEventArgs e)
{

Console.WriteLine(displayString[counter ++ % displayString.Length]));

}

}

}

Chapter 11 code