Learn 2 CSharp 1

1. Display series of numbers (1,2,3,4, 5....etc) in an infinite loop. The program should quit if someone hits a specific key (Say ESCAPE key). using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading; namespace lrn2CSharp1 { class Program { static void Main( string[ ] args ) { for ( int i = 0; ; i++ ) { if ( Console.KeyAvailable && keyPressHandler( Console.ReadKey( true ) ) ) break; Console.Write( i + " " ); Thread.Sleep( 250 ); } } protected static Boolean keyPressHandler( ConsoleKeyInfo input ) { if ( input.Key == ConsoleKey.Escape ) return true; return false; } } }

posted by dharh 7:13 PM Feb 10th, 2008



2024: 1
2023: 4 2 1
2022: 5 3
2011: 5 3 1
2010: 12 9 7 1
2009: 12 11 8 5
2008: 12 5 4 3 2 1
2007: 12 11 10 9 8 7 6 5 4 3 2 1
2006: 12 11 10 9 8 7 6 5 4 3 2 1
2005: 12 10 7 6
2004: 10 9 6 5 4 3 2 1