复制代码 代码如下:
 
string[] arr = s.Split (','); 
复制代码 代码如下:
 
Dictionary<string, int> Statistics = new Dictionary<string, int>(); 
复制代码 代码如下:
 
foreach (string w in arr) 
{ 
if (Statistics.ContainsKey(w)) 
{ 
Statistics[w] += 1; 
} 
else 
{ 
Statistics[w] = 1; 
} 
} 
复制代码 代码如下:
 
<asp:Repeater runat="server"> 
<HeaderTemplate> 
<table cellpadding="1" cellspacing="0"> 
<tr> 
<td>字符 </td> 
<td>次数 </td> 
</tr> 
</HeaderTemplate> 
<ItemTemplate> 
<tr> 
<td> 
<%# Eval("key") %> 
</td> 
<td> 
<%# Eval("value") %> 
</td> 
</tr> 
</ItemTemplate> 
<FooterTemplate> 
</table> 
</FooterTemplate> 
</asp:Repeater> 
复制代码 代码如下:
 
protected void Page_Load(object sender, EventArgs e) 
{ 
this.Repeater1.DataSource = Statistics; 
this.Repeater1.DataBind(); 
} 
新闻热点
疑难解答
图片精选