if (text != "" || text != null)
myList[i] = text;
myList is string array But in the end of the loop i keep see in myList items that are "" or null.
WindowSnap[] windowsarray = WindowSnap.GetAllWindows(true, true).ToArray();
this.listBoxSnap.BeginUpdate();
this.listBoxSnap.Items.Clear();
this.listBoxSnap.Items.AddRange(windowsarray);
string[] myList = new string[listBoxSnap.Items.Count];
for (int i = listBoxSnap.Items.Count - 1; i >= 0; i--)
{
string tt = listBoxSnap.Items[i].ToString();
int first = tt.IndexOf("Text: ");
int second = tt.IndexOf(",", first + 6);
string text = tt.Substring(first + 6, second - first - 6);
if (text != "" || text != null)
myList[i] = text;
}
I tried inside the loop and after the loop the line:
myList.Where(x => !string.IsNullOrEmpty(x)).ToArray();
But still there are items with ""