You've got a couple of problems.
1. You didn't instantiate your "web" variable. You have to say:
- Code: Select all
info web=new info();
2. If you want to call a function using an instance of your struct (web.find("//")) then the function can't be static.
That's all the errors I could find, but while I'm at it thought I'd also drop a few comments about your programming logic (I'm feeling a bit patronizing this morning....).
If I was you I wouldn't have "info" be a struct, a class would make more sense. I would then make the "find" function private and the class would then find and store the page elements. Elements would be written into private string variables using functions and then use getters/setters to make then visible (read-only). Output would then be done in the main program, not the in the class.
I haven't tested this, but it does compile....:
- Code: Select all
class info {
private string h1;
public string H1 {
get {
return h1;
}
}
public void findH1() {
h1=find(@"<h1>(.)+</h1>");
}
private string find(string reg) {
Regex r=new Regex(reg);
Match m=r.Match(output);
return m.ToString();
}
}