Click here to Skip to main content
16,008,183 members
Home / Discussions / C#
   

C#

 
GeneralRe: Extract Data from XML -> DataSet -> DataGrid Pin
John Fisher13-Mar-04 7:57
John Fisher13-Mar-04 7:57 
GeneralConsole Application Pin
mil_an13-Mar-04 3:58
mil_an13-Mar-04 3:58 
GeneralRe: Console Application Pin
John Fisher13-Mar-04 4:26
John Fisher13-Mar-04 4:26 
GeneralRe: Console Application Pin
mil_an13-Mar-04 10:24
mil_an13-Mar-04 10:24 
GeneralRe: Console Application Pin
Nick Parker13-Mar-04 10:45
protectorNick Parker13-Mar-04 10:45 
GeneralRe: Console Application Pin
mil_an13-Mar-04 8:12
mil_an13-Mar-04 8:12 
GeneralRe: Console Application Pin
CWIZO13-Mar-04 8:28
CWIZO13-Mar-04 8:28 
GeneralRe: Console Application Pin
oOomen13-Mar-04 22:11
oOomen13-Mar-04 22:11 
hi, here is everything u need Wink | ;-)
i hope it helps u!

<br />
using System;<br />
using System.Threading; // needs to use Thread class<br />
<br />
namespace ConsoleApplication1<br />
{<br />
	// the class with main function<br />
	class Class<br />
	{<br />
		/// <summary><br />
		/// The main entry point for the application.<br />
		/// </summary><br />
		static void Main()<br />
		{<br />
			// create new Traffic_light object <br />
			Traffic_light t_l = new Traffic_light();<br />
<br />
			// loop 10 times<br />
			for(int i = 0; i < 10; i ++)<br />
			{<br />
				t_l.ShowState(); // show current state<br />
				Thread.Sleep(5000); // wait 5 seconds<br />
			}<br />
			// show exit msg.<br />
			Console.WriteLine("press enter to exit");<br />
			Console.ReadLine();<br />
		}<br />
	}<br />
	<br />
	// the class u need<br />
	class Traffic_light<br />
	{<br />
		// array with ur states<br />
		private string[] Array;<br />
<br />
		// index of currrent state<br />
		private int State;<br />
<br />
		// Constructor to set up default values<br />
		public Traffic_light()<br />
		{<br />
			State = 0;<br />
			Array = new string[] {	"prepare to go",<br />
									"go",<br />
									"prepare to stop",<br />
									"stop"	};<br />
		}<br />
<br />
		// function u need to show current state<br />
		// new call - new state<br />
		public void ShowState()<br />
		{<br />
			State %= Array.Length; // same as: State = State % Array.Length;<br />
			Console.WriteLine(Array[State ++]); // same as: Console.WriteLine(Array[State]); State = State + 1;<br />
		}<br />
	}<br />
}<br />
<br />


output u see:
====================
prepare to go
go
prepare to stop
stop
prepare to go
go
prepare to stop
stop
prepare to go
go
press enter to exit
====================
best regards !Smile | :)
QuestionHow can a class call one of its own accessors? Pin
Adrian Stanley13-Mar-04 3:57
Adrian Stanley13-Mar-04 3:57 
AnswerRe: How can a class call one of its own accessors? Pin
John Fisher13-Mar-04 4:20
John Fisher13-Mar-04 4:20 
AnswerRe: How can a class call one of its own accessors? Pin
Jeff Varszegi13-Mar-04 16:15
professionalJeff Varszegi13-Mar-04 16:15 
AnswerRe: How can a class call one of its own accessors? Pin
Michael Flanakin17-Mar-04 19:19
Michael Flanakin17-Mar-04 19:19 
GeneralDataGrid Sorting Pin
jazzle13-Mar-04 3:37
jazzle13-Mar-04 3:37 
GeneralRe: DataGrid Sorting Pin
Mazdak13-Mar-04 9:40
Mazdak13-Mar-04 9:40 
GeneralRe: DataGrid Sorting Pin
jazzle13-Mar-04 10:42
jazzle13-Mar-04 10:42 
GeneralRe: DataGrid Sorting Pin
Mazdak13-Mar-04 18:30
Mazdak13-Mar-04 18:30 
GeneralRe: DataGrid Sorting Pin
jazzle14-Mar-04 1:41
jazzle14-Mar-04 1:41 
GeneralRe: DataGrid Sorting Pin
jazzle14-Mar-04 9:52
jazzle14-Mar-04 9:52 
GeneralRe: DataGrid Sorting Pin
Mazdak14-Mar-04 9:57
Mazdak14-Mar-04 9:57 
GeneralRe: DataGrid Sorting Pin
jazzle14-Mar-04 10:07
jazzle14-Mar-04 10:07 
Generalhelp me Pin
vatavua13-Mar-04 3:21
vatavua13-Mar-04 3:21 
GeneralRe: help me Pin
Dave Kreskowiak13-Mar-04 4:26
mveDave Kreskowiak13-Mar-04 4:26 
GeneralRe: help me Pin
Corinna John13-Mar-04 8:18
Corinna John13-Mar-04 8:18 
GeneralRender child controls into memory dc Pin
Mathew Hall13-Mar-04 2:18
Mathew Hall13-Mar-04 2:18 
GeneralBit to Byte and base type size in C# Pin
Tristan Rhodes13-Mar-04 1:25
Tristan Rhodes13-Mar-04 1:25 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.