Click here to Skip to main content
15,918,243 members
Home / Discussions / C#
   

C#

 
AnswerRe: Foreach Pin
Abhinav S2-Oct-10 6:44
Abhinav S2-Oct-10 6:44 
GeneralRe: Foreach Pin
Saksida Bojan2-Oct-10 6:54
Saksida Bojan2-Oct-10 6:54 
GeneralRe: Foreach Pin
Luc Pattyn2-Oct-10 6:59
sitebuilderLuc Pattyn2-Oct-10 6:59 
GeneralRe: Foreach Pin
Saksida Bojan2-Oct-10 7:06
Saksida Bojan2-Oct-10 7:06 
AnswerRe: Foreach Pin
Luc Pattyn2-Oct-10 6:57
sitebuilderLuc Pattyn2-Oct-10 6:57 
GeneralRe: Foreach Pin
Saksida Bojan2-Oct-10 7:13
Saksida Bojan2-Oct-10 7:13 
GeneralRe: Foreach Pin
Luc Pattyn2-Oct-10 7:38
sitebuilderLuc Pattyn2-Oct-10 7:38 
AnswerRe: Foreach Pin
Henry Minute2-Oct-10 7:05
Henry Minute2-Oct-10 7:05 
Assuming, for the sake of this answer, that GetProcessFromSystem() returns a List<Process> it would be better to do:
C#
List<Process> procs = GetProcessFromSystem();

foreach (Process proc in procs)
{
    ............
    ............
}


Doing it the way you first proposed would be more greedy for system resources as (I think) GPFS() would be called on each iteration of the foreach loop, consuming resources. In addition the list could easily change, items might be added or even removed. Anything implementing <code>IEnumerable can give unpredictable results, especially if things are removed from the list.
Henry Minute

Do not read medical books! You could die of a misprint. - Mark Twain
Girl: (staring) "Why do you need an icy cucumber?"
“I want to report a fraud. The government is lying to us all.”

GeneralRe: Foreach Pin
Luc Pattyn2-Oct-10 7:35
sitebuilderLuc Pattyn2-Oct-10 7:35 
GeneralRe: Foreach Pin
Henry Minute2-Oct-10 7:44
Henry Minute2-Oct-10 7:44 
GeneralRe: Foreach Pin
Luc Pattyn2-Oct-10 7:45
sitebuilderLuc Pattyn2-Oct-10 7:45 
GeneralRe: Foreach Pin
Henry Minute2-Oct-10 7:46
Henry Minute2-Oct-10 7:46 
GeneralRe: Foreach Pin
Dave Kreskowiak2-Oct-10 7:39
mveDave Kreskowiak2-Oct-10 7:39 
GeneralRe: Foreach Pin
Henry Minute2-Oct-10 7:45
Henry Minute2-Oct-10 7:45 
GeneralRe: Foreach Pin
Dave Kreskowiak2-Oct-10 10:04
mveDave Kreskowiak2-Oct-10 10:04 
GeneralRe: Foreach Pin
Luc Pattyn2-Oct-10 10:22
sitebuilderLuc Pattyn2-Oct-10 10:22 
GeneralRe: Foreach Pin
Henry Minute2-Oct-10 10:55
Henry Minute2-Oct-10 10:55 
GeneralRe: Foreach Pin
Luc Pattyn2-Oct-10 11:06
sitebuilderLuc Pattyn2-Oct-10 11:06 
GeneralRe: Foreach Pin
Henry Minute2-Oct-10 11:09
Henry Minute2-Oct-10 11:09 
GeneralRe: Foreach Pin
Luc Pattyn2-Oct-10 11:20
sitebuilderLuc Pattyn2-Oct-10 11:20 
QuestionConvert monochrome bitmap to ascii string to send to QLS-printer? Pin
Mats Eurén2-Oct-10 5:38
Mats Eurén2-Oct-10 5:38 
AnswerRe: Convert monochrome bitmap to ascii string to send to QLS-printer? Pin
Luc Pattyn2-Oct-10 5:45
sitebuilderLuc Pattyn2-Oct-10 5:45 
GeneralRe: Convert monochrome bitmap to ascii string to send to QLS-printer? Pin
Mats Eurén2-Oct-10 6:09
Mats Eurén2-Oct-10 6:09 
GeneralRe: Convert monochrome bitmap to ascii string to send to QLS-printer? Pin
Luc Pattyn2-Oct-10 6:16
sitebuilderLuc Pattyn2-Oct-10 6:16 
GeneralRe: Convert monochrome bitmap to ascii string to send to QLS-printer? Pin
Dave Kreskowiak2-Oct-10 6:17
mveDave Kreskowiak2-Oct-10 6:17 

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.