c#问题?

ljb07976513524 2009-04-20 05:45:18
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;

namespace ConsoleApplication1
{
class Program
{
class people
{
public string name;
public string sex;
public string number;
public string ID;




}



static void Main(string[] args)
{
List<people> student = new List<people>();

StreamWriter f2 = new StreamWriter(@"jjj.txt", false, Encoding.GetEncoding("gb2312"));


bool key = true;
while (key!=false)
{
Console.WriteLine("请输入你需要统计的人数");
int num = Convert.ToInt32(Console.ReadLine());
for (int i = 0; i < num; i++)
{
people stu = new people();
Console.WriteLine("请输入你的姓名");
stu.name = Console.ReadLine();
f2.WriteLine(stu.name);
Console.WriteLine("请输入你的性别");
stu.sex = Console.ReadLine();
f2.WriteLine(stu.sex);
Console.WriteLine("请输入你的学好");
stu.number = Console.ReadLine();
f2.WriteLine(stu.number);
Console.WriteLine("请输入你的地址");
stu.ID = Console.ReadLine();
f2.WriteLine(stu.ID);
student.Add(stu);
Console.WriteLine("添加成功");


}


FileStream fs = new FileStream(@"jjj.txt", FileMode.Open, FileAccess.Read, FileShare.ReadWrite);

StreamReader sr = new StreamReader(fs, Encoding.GetEncoding("gb2312"));


string st = sr.ReadToEnd();
Console.WriteLine(st);
Console.WriteLine("是否继续。.........");
char key1 = Convert.ToChar(Console.ReadLine());
if (key1 == 'y' || key1 == 'Y')
key = true;
if (key1 == 'N' || key1 == 'n')
key = false;


}

f2.Close();

Console.ReadKey();


}
}
}

我想通过 输入后
能过不断输入。。并打印出来。。
但是这个程序不能打印出。。
请高手指教...
...全文
50 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
ljb07976513524 2009-04-20
  • 打赏
  • 举报
回复
我想通过
string st = sr.ReadToEnd();
Console.WriteLine(st);
把以前的输入进去的都输出来。。。
但是输不出来
ericzhangbo1982111 2009-04-20
  • 打赏
  • 举报
回复
FileStream fs = new FileStream(@"jjj.txt", FileMode.Open, FileAccess.Read, FileShare.ReadWrite);

StreamReader sr = new StreamReader(fs, Encoding.GetEncoding("gb2312"));


string st = sr.ReadToEnd();
Console.WriteLine(st);
sr.Close();
fs.Close();

111,126

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • Creator Browser
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧