Click here to Skip to main content
15,891,733 members
Home / Discussions / C#
   

C#

 
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 
QuestionProtection for excel sheet Pin
iet20009-Oct-07 21:17
iet20009-Oct-07 21:17 
Questionclass problem Pin
ptvce9-Oct-07 21:13
ptvce9-Oct-07 21:13 
AnswerRe: class problem Pin
Martin#9-Oct-07 21:23
Martin#9-Oct-07 21:23 
GeneralRe: class problem Pin
ptvce9-Oct-07 21:40
ptvce9-Oct-07 21:40 
GeneralRe: class problem Pin
Martin#9-Oct-07 21:48
Martin#9-Oct-07 21:48 
GeneralRe: class problem Pin
Bekjong9-Oct-07 22:00
Bekjong9-Oct-07 22:00 
QuestionBlinking a form Alert Pin
joemonvarghese9-Oct-07 20:59
joemonvarghese9-Oct-07 20:59 
AnswerRe: Blinking a form Alert Pin
JF201510-Oct-07 0:01
JF201510-Oct-07 0:01 
QuestionWhat is SSL Encryption means ? how to get ssl encryption Pin
Satish_S9-Oct-07 19:16
Satish_S9-Oct-07 19:16 
AnswerRe: What is SSL Encryption means ? how to get ssl encryption Pin
N a v a n e e t h9-Oct-07 20:58
N a v a n e e t h9-Oct-07 20:58 
GeneralRe: What is SSL Encryption means ? how to get ssl encryption Pin
Satish_S9-Oct-07 21:12
Satish_S9-Oct-07 21:12 
GeneralRe: What is SSL Encryption means ? how to get ssl encryption Pin
N a v a n e e t h9-Oct-07 21:25
N a v a n e e t h9-Oct-07 21:25 
GeneralRe: What is SSL Encryption means ? how to get ssl encryption Pin
Satish_S10-Oct-07 18:36
Satish_S10-Oct-07 18:36 
GeneralRe: What is SSL Encryption means ? how to get ssl encryption Pin
N a v a n e e t h10-Oct-07 22:28
N a v a n e e t h10-Oct-07 22:28 
GeneralRe: Pin
Satish_S9-Oct-07 21:12
Satish_S9-Oct-07 21:12 
Questionstored procedure vs class coding Pin
VG Ramanan9-Oct-07 18:57
VG Ramanan9-Oct-07 18:57 

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.