Click here to Skip to main content
15,900,724 members
Home / Discussions / C#
   

C#

 
QuestionMdi Child Menu Pin
Stevo Z9-Oct-07 22:27
Stevo Z9-Oct-07 22:27 
AnswerRe: Mdi Child Menu Pin
Stevo Z9-Oct-07 23:24
Stevo Z9-Oct-07 23:24 
QuestionSearching strings in resource files Pin
AndrusM9-Oct-07 21:56
AndrusM9-Oct-07 21:56 
Questionbookmarks in word Pin
Nitin.raj9-Oct-07 21:53
Nitin.raj9-Oct-07 21:53 
AnswerRe: bookmarks in word Pin
Pete O'Hanlon9-Oct-07 23:01
mvePete O'Hanlon9-Oct-07 23:01 
QuestionLocalize Combo Box Dropdown Pin
Student119-Oct-07 21:36
Student119-Oct-07 21:36 
AnswerRe: Localize Combo Box Dropdown Pin
TJoe10-Oct-07 6:27
TJoe10-Oct-07 6:27 
GeneralRe: Localize Combo Box Dropdown Pin
Student1110-Oct-07 12:09
Student1110-Oct-07 12:09 
AnswerRe: Localize Combo Box Dropdown Pin
TJoe11-Oct-07 2:32
TJoe11-Oct-07 2:32 
GeneralRe: Localize Combo Box Dropdown Pin
Student1111-Oct-07 19:15
Student1111-Oct-07 19:15 
QuestionRe: Localize Combo Box Dropdown Pin
TJoe12-Oct-07 1:55
TJoe12-Oct-07 1:55 
AnswerRe: Localize Combo Box Dropdown Pin
Student1112-Oct-07 2:18
Student1112-Oct-07 2:18 
GeneralRe: Localize Combo Box Dropdown Pin
TJoe12-Oct-07 2:25
TJoe12-Oct-07 2:25 
Questionapply foreach in a byte[] ArrayList Pin
Patricio Tapia9-Oct-07 21:24
Patricio Tapia9-Oct-07 21:24 
AnswerRe: apply foreach in a byte[] ArrayList Pin
JoeSharp9-Oct-07 21:56
JoeSharp9-Oct-07 21:56 
AnswerDo you mean... Pin
CPallini9-Oct-07 22:02
mveCPallini9-Oct-07 22:02 
GeneralRe: Do you mean... Pin
Martin#9-Oct-07 22:05
Martin#9-Oct-07 22:05 
GeneralOf course I know, but Pin
CPallini9-Oct-07 22:23
mveCPallini9-Oct-07 22:23 
GeneralRe: Of course I know that you know, but Pin
Martin#9-Oct-07 22:28
Martin#9-Oct-07 22:28 
GeneralBecause Pin
CPallini9-Oct-07 22:34
mveCPallini9-Oct-07 22:34 
GeneralRe: True Pin
Martin#9-Oct-07 22:41
Martin#9-Oct-07 22:41 
GeneralRe: True Pin
Patricio Tapia9-Oct-07 23:01
Patricio Tapia9-Oct-07 23:01 
GeneralRe: True Pin
Martin#9-Oct-07 23:06
Martin#9-Oct-07 23:06 
AnswerRe: apply foreach in a byte[] ArrayList Pin
Martin#9-Oct-07 22:02
Martin#9-Oct-07 22:02 
Hello,

This will work if you only Add "byte[]"'s to your List.
byte[] actArray1 = new byte[5];
byte[] actArray2 = new byte[6];
ArrayList actList = new ArrayList();
 
actList.Add(actArray1);
actList.Add(actArray2);
 
foreach(byte[] actArray in actList)
{
	int length = actArray.Length;
}

But will throw an exception (System.InvalidCastException') if you also add different types to the List:
byte[] actArray1 = new byte[5];
byte[] actArray2 = new byte[6];
Control actControl = new Control();
ArrayList actList = new ArrayList();
 
actList.Add(actArray1);
actList.Add(actArray2);
actList.Add(actControl);
 
foreach(byte[] actArray in actList)  //will throw the exception here
{
	int length = actArray.Length;
}

There for you could use:
byte[] actArray1 = new byte[5];
byte[] actArray2 = new byte[6];
Control actControl = new Control();
ArrayList actList = new ArrayList();
 
actList.Add(actArray1);
actList.Add(actArray2);
actList.Add(actControl);
 
foreach(object actObject in actList)
{
	byte[] actArray = actObject as byte[];
	if(actArray!=null)
	{
		int length = actArray.Length;
	}
}


IF you are using framework > .Net1.1, you could use a generic list.

All the best,

Martin

GeneralRe: apply foreach in a byte[] ArrayList Pin
Patricio Tapia9-Oct-07 22:34
Patricio Tapia9-Oct-07 22:34 

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.