Click here to Skip to main content
15,907,329 members
Home / Discussions / C#
   

C#

 
GeneralRe: write bytes to a file Pin
WhiteGirl239-Jul-07 20:21
WhiteGirl239-Jul-07 20:21 
QuestionException Pin
sangramkp9-Jul-07 2:34
sangramkp9-Jul-07 2:34 
AnswerRe: Exception Pin
valerian.precop9-Jul-07 2:41
valerian.precop9-Jul-07 2:41 
GeneralRe: Exception Pin
sangramkp9-Jul-07 2:58
sangramkp9-Jul-07 2:58 
GeneralRe: Exception Pin
J4amieC9-Jul-07 3:08
J4amieC9-Jul-07 3:08 
GeneralRe: Exception Pin
sangramkp9-Jul-07 3:13
sangramkp9-Jul-07 3:13 
GeneralRe: Exception Pin
sangramkp9-Jul-07 3:21
sangramkp9-Jul-07 3:21 
AnswerRe: Exception Pin
Luc Pattyn9-Jul-07 2:43
sitebuilderLuc Pattyn9-Jul-07 2:43 
Hi,

a ListBox item can have any type you choose, all the items in a ListBox
dont even have to have the same type.

Foreach insists that each item in the collection has the indicated type,
otherwise an Exception will be trown.
If the types differ and you want to process only one of the types, say you
only want to process the strings, then do the following:

foreach (object item in collection) {
    string str=item as string;
    if (str!=null) {
        .. handle the str
    }
}


Smile | :)


GeneralRe: Exception Pin
sangramkp9-Jul-07 3:10
sangramkp9-Jul-07 3:10 
GeneralRe: Exception Pin
Luc Pattyn9-Jul-07 3:19
sitebuilderLuc Pattyn9-Jul-07 3:19 
GeneralRe: Exception Pin
ruanr9-Jul-07 3:32
ruanr9-Jul-07 3:32 
GeneralRe: Exception Pin
Luc Pattyn9-Jul-07 3:47
sitebuilderLuc Pattyn9-Jul-07 3:47 
GeneralRe: Exception Pin
Not Active9-Jul-07 3:52
mentorNot Active9-Jul-07 3:52 
GeneralRe: Exception Pin
Luc Pattyn9-Jul-07 3:59
sitebuilderLuc Pattyn9-Jul-07 3:59 
QuestionFor and next loop... problem Pin
smguc9-Jul-07 2:28
smguc9-Jul-07 2:28 
AnswerRe: For and next loop... problem Pin
valerian.precop9-Jul-07 2:46
valerian.precop9-Jul-07 2:46 
AnswerRe: For and next loop... problem Pin
Corinna John9-Jul-07 2:49
Corinna John9-Jul-07 2:49 
AnswerRe: For and next loop... problem Pin
V.9-Jul-07 3:24
professionalV.9-Jul-07 3:24 
GeneralRe: For and next loop... problem Pin
smguc9-Jul-07 12:28
smguc9-Jul-07 12:28 
GeneralRe: For and next loop... problem Pin
V.9-Jul-07 20:07
professionalV.9-Jul-07 20:07 
QuestionDo something while the mouse button is down Pin
Dana Tov9-Jul-07 2:21
Dana Tov9-Jul-07 2:21 
AnswerRe: Do something while the mouse button is down Pin
Colin Angus Mackay9-Jul-07 2:30
Colin Angus Mackay9-Jul-07 2:30 
QuestionRe: Do something while the mouse button is down Pin
Dana Tov9-Jul-07 2:44
Dana Tov9-Jul-07 2:44 
AnswerRe: Do something while the mouse button is down Pin
Luc Pattyn9-Jul-07 2:48
sitebuilderLuc Pattyn9-Jul-07 2:48 
AnswerRe: Do something while the mouse button is down Pin
sam#9-Jul-07 3:14
sam#9-Jul-07 3:14 

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.