Click here to Skip to main content
15,914,444 members
Home / Discussions / C#
   

C#

 
GeneralCapturing HTML as Image Pin
smeese21-Sep-04 18:09
smeese21-Sep-04 18:09 
GeneralRe: Capturing URL as Image Pin
eggie522-Sep-04 18:14
eggie522-Sep-04 18:14 
GeneralRe: Capturing URL as Image Pin
smeese23-Sep-04 2:37
smeese23-Sep-04 2:37 
GeneralThreading Puzzles. Pin
stan2821-Sep-04 15:21
stan2821-Sep-04 15:21 
GeneralRe: Threading Puzzles. Pin
Nick Parker21-Sep-04 17:14
protectorNick Parker21-Sep-04 17:14 
GeneralRe: Threading Puzzles. Pin
stan2822-Sep-04 7:41
stan2822-Sep-04 7:41 
GeneralRe: Threading Puzzles. Pin
stan2823-Sep-04 4:39
stan2823-Sep-04 4:39 
GeneralArray Problem Pin
Milan200721-Sep-04 14:56
Milan200721-Sep-04 14:56 
I am new to C# and I am having some problem understanding arrays. I am getting the following exception:
An unhandled exception of type 'System.FormatException' occurred in mscorlib.dll

Additional information: Index (zero based) must be greater than or equal to zero and less than the size of the argument list.

The problem seems to be (string)ie.Current. I do not understand why I cannot retrieve the value. Any ideas would be appreciated.

<br />
using System;<br />
using System.Collections;<br />
<br />
namespace ConsoleApplication2 <br />
{<br />
<br />
	class Class1 <br />
	{<br />
<br />
		[STAThread]<br />
		static void Main(string[] args) <br />
		{<br />
			Hashtable region = new Hashtable();<br />
			IDictionaryEnumerator ide; // to walk thru the hashtable<br />
			ArrayList al;<br />
			IEnumerator ie; // to walk thru an arraylist<br />
			string indicator = "";  <br />
<br />
			do <br />
			{<br />
				Console.Write("Enter region name: ");	<br />
				region.Add(Console.ReadLine(), new ArrayList());			<br />
			<br />
				Console.Write("Enter another region? (y/n): ");<br />
				indicator = Console.ReadLine();<br />
<br />
			} while(indicator.ToUpper() == "Y");<br />
			<br />
			// walk the hashtable and add a single string ("foo") to each arraylist<br />
			ide = region.GetEnumerator();<br />
			while (ide.MoveNext()) <br />
			{<br />
				al = (ArrayList)ide.Value;<br />
				al.Add("foo");<br />
			}<br />
<br />
			// now walk the hashtable AND arraylists to print everything<br />
			ide = region.GetEnumerator();<br />
			while (ide.MoveNext()) <br />
			{<br />
				al = (ArrayList)ide.Value;<br />
				ie = al.GetEnumerator();<br />
				 while (ie.MoveNext()) <br />
				{<br />
					Console.WriteLine("hash key: {1}  array value: {2}",(string)ide.Key, (string)ie.Current);<br />
				} <br />
<br />
				Console.WriteLine(ide.Key);<br />
				Console.WriteLine(ide.Current);<br />
			}<br />
<br />
			Console.ReadLine();<br />
		}<br />
	}<br />
<br />
<br />
}<br />

GeneralRe: Array Problem Pin
Christian Graus21-Sep-04 15:21
protectorChristian Graus21-Sep-04 15:21 
GeneralRe: Array Problem Pin
Milan200721-Sep-04 15:22
Milan200721-Sep-04 15:22 
GeneralRe: Array Problem Pin
Christian Graus21-Sep-04 15:28
protectorChristian Graus21-Sep-04 15:28 
GeneralRe: Array Problem Pin
Milan200721-Sep-04 15:33
Milan200721-Sep-04 15:33 
GeneralRe: Array Problem Pin
Christian Graus21-Sep-04 15:44
protectorChristian Graus21-Sep-04 15:44 
GeneralRe: Array Problem Pin
Milan200721-Sep-04 15:54
Milan200721-Sep-04 15:54 
GeneralRe: Array Problem Pin
Christian Graus21-Sep-04 15:57
protectorChristian Graus21-Sep-04 15:57 
GeneralRe: Array Problem Pin
Milan200721-Sep-04 16:01
Milan200721-Sep-04 16:01 
GeneralGPS Pin
mathon21-Sep-04 14:00
mathon21-Sep-04 14:00 
GeneralRe: GPS Pin
Heath Stewart21-Sep-04 14:12
protectorHeath Stewart21-Sep-04 14:12 
GeneralRessources Exception in .NET Frameworks 2.0 Pin
Elc3p421-Sep-04 13:20
Elc3p421-Sep-04 13:20 
GeneralRe: Ressources Exception in .NET Frameworks 2.0 Pin
Heath Stewart21-Sep-04 14:27
protectorHeath Stewart21-Sep-04 14:27 
Generalembedding a resource and getting it back out Pin
vista2721-Sep-04 12:42
vista2721-Sep-04 12:42 
GeneralRe: embedding a resource and getting it back out Pin
Heath Stewart21-Sep-04 14:20
protectorHeath Stewart21-Sep-04 14:20 
GeneralHelp :) Pin
Moon Boy21-Sep-04 11:19
Moon Boy21-Sep-04 11:19 
GeneralRe: Help :) Pin
Heath Stewart21-Sep-04 11:36
protectorHeath Stewart21-Sep-04 11:36 
GeneralUsing the Command Prompt in C# Win App Pin
chubbysilk21-Sep-04 10:06
chubbysilk21-Sep-04 10:06 

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.