3
Reply

help with doing something only when the property matches a certain string

minaaj

minaaj

Nov 18 2010 4:42 AM
11.3k


Hi All,
With the following code I write running processes to a listbox:

------------------------------------------------------------
Process[] procs;
        private void Getprocs()
        {
            procs = Process.GetProcesses();
            if (Convert.ToInt32(label2.Text) != procs.Length)
            {
                listBox1.Items.Clear();
                for (int i = 0; i < procs.Length; i++)
                {
                    listBox1.Items.Add(procs[i].MainWindowTitle);
                }
                label2.Text = procs.Length.ToString();
            }
        }
---------------------------------------------------------
The problem is the I ONLY want to write those processes to the list where the Process.MainWindowTitle property does not match "nothing".

To find this out i use: (procs[i].MainWindowTitle != "")

How can I incoporate this check with my code ?
 
Thanks !

Answers (3)