StreamReader srr = new StreamReader(File.OpenRead("saved"));
string[] slist = srr.ReadToEnd().Split('}');
System.Collections.Specialized.StringCollection clist = new System.Collections.Specialized.StringCollection();
for (int i = 0; i < slist.Length; i++) {
if (slist[i].Trim != "") // ERROR IS HERE
{
clist.Add(slist[i]);
}
}
From another section of my program I’m saving the current list of files in the clipboard to a file, and doing that by seperating each path with “}” so kind of like ( C:}D:}C:\Windows\Media} ). Then here, I am opening the file, splitting it into a string array then i need to check wether the each path is an empty string but visual studio says “Operator ‘!=’ cannot be applied to operands of type ‘method group’ and ‘string'”. I am not comparing the string array directly to the string though (slist[i]) so what is causing this, is it just a problem with VS or am i missing something?
Call Trim():
if(slist[i].Trim() != "")