level 1
a4617424687
楼主
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.IO;
using System.Collections;
public partial class _1 : System.Web.UI.Page
{
ArrayList count = new ArrayList();
protected void Page_Load(object sender, EventArgs e)
{
getvote();
}
protected void getvote()
{
string file = Server.MapPath("tp.txt");
StreamReader sr = File.OpenText(file);
while(sr.Peek()!=-1)
{
string str=sr.ReadLine();
string[]strtp=str.Split('|');
foreach (string ss in strtp)
count.Add(int.Parse(ss));
}
sr.Close();
}
protected void putvote()
{
string aa = Server.MapPath("tp.txt");
if (File.Exists(aa))
{
StreamWriter se = new StreamWriter(aa,false);
string str = count[0].ToString();
for(int i=1;i<count.Count;i++)
str+="|"+count[i].ToString();
}
}
protected void Button2_Click(object sender, EventArgs e)
{
getvote();
Label2.Text = "各候选人票数:<br/>";
for (int i = 0; i < RadioButtonList1.Items.Count; i++)
{
Label2.Text += RadioButtonList1.Items[i].Value + ": " +count[i]+ "票" + "<br/>";
}
}
}
2015年04月22日 11点04分
1
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.IO;
using System.Collections;
public partial class _1 : System.Web.UI.Page
{
ArrayList count = new ArrayList();
protected void Page_Load(object sender, EventArgs e)
{
getvote();
}
protected void getvote()
{
string file = Server.MapPath("tp.txt");
StreamReader sr = File.OpenText(file);
while(sr.Peek()!=-1)
{
string str=sr.ReadLine();
string[]strtp=str.Split('|');
foreach (string ss in strtp)
count.Add(int.Parse(ss));
}
sr.Close();
}
protected void putvote()
{
string aa = Server.MapPath("tp.txt");
if (File.Exists(aa))
{
StreamWriter se = new StreamWriter(aa,false);
string str = count[0].ToString();
for(int i=1;i<count.Count;i++)
str+="|"+count[i].ToString();
}
}
protected void Button2_Click(object sender, EventArgs e)
{
getvote();
Label2.Text = "各候选人票数:<br/>";
for (int i = 0; i < RadioButtonList1.Items.Count; i++)
{
Label2.Text += RadioButtonList1.Items[i].Value + ": " +count[i]+ "票" + "<br/>";
}
}
}