大家好我搜索IEnumerator,但無法理解it.It會很大的幫助,如果有人幫助我。IEnumerator的目的是什麼
基本上是試圖理解它在這個代碼
string requestUriString = URL;
if (requestUriString.IndexOf("http://", StringComparison.InvariantCultureIgnoreCase) < 0)
{
requestUriString = "http://" + requestUriString;
}
WebRequest request = WebRequest.Create(requestUriString);
try
{
IEnumerator enumerator;
StreamReader reader = new StreamReader(request.GetResponse().GetResponseStream(), Encoding.UTF8);
string sSourceString = reader.ReadToEnd();
reader.Close();
string str6 = this.funcParseStringFromString2String(sSourceString, "<div class=\"title\">", "<div class=\"searches_related\">", false);
ArrayList list = new ArrayList();
list = this.funcParseStringFromString2Stringx(str6, "<h3><a ", "</h3>", false);
int num = this.DataGridView2.RowCount + 1;
try
{
enumerator = list.GetEnumerator();
while (enumerator.MoveNext())
{
string str8 = Conversions.ToString(enumerator.Current);
string str7 = this.funcParseStringFromString2String(str8, "title=\"", "\" href=", false);
string str5 = this.funcParseStringFromString2String(str8, "\" href=\"", "\">", false).Replace("\" class=\"rated", "");
this.DataGridView2.Rows.Add(new string[] { Conversions.ToString(num), Conversions.ToString(false), str7, str5 });
this.lblInsProg.Text = "Done: " + Conversions.ToString(this.DataGridView2.Rows.Count) + " Articles found";
num++;
}
}
finally
{
if (enumerator is IDisposable)
{
(enumerator as IDisposable).Dispose();
}
}
if (list.Count == 0)
{
this.lblInsProg.Text = "No results found for " + this.search.Text + "!";
this.Button11.Enabled = false;
}
else
{
this.Button11.Enabled = true;
}
if (this.DataGridView2.RowCount != 0)
{
this.Button15.Visible = true;
}
return Conversions.ToString(0);
}
catch (WebException exception1)
{
ProjectData.SetProjectError(exception1);
WebException exception = exception1;
ProjectData.ClearProjectError();
}
return Conversions.ToString(0);
我真的希望這不是你作爲考慮碼值得借鑑的東西。 – 2011-02-07 21:40:31
是的,這是一些........代碼 – 2011-02-07 21:50:17