mardi 8 septembre 2015

When using substring, An object reference is required for the nonstatic field, method, or property

I am using String.Substring to pull text out of the middle of a string. When looking on stackoverflow I see many places where people asked about this for class properties and they said to put static in front of it. I don't think that would help in my case but I tried anyway and still received the error. How do I get rid of this error when not using a property?

Here is the code:

string filename = String.Substring(1, fileName.IndexOf(')'));
string fileGuid = String.Substring(fileName.IndexOf(')') + 1, 16);

if (String.Substring(fileName.IndexOf('(') + 1, 4) == "html")

Aucun commentaire:

Enregistrer un commentaire