如何在C#中实现查看功能
using System;using System.Text;
using
class A
{
public static void Main()
{
B();
Console.Write("请按[ENTER]键继续...");
Console.ReadLine();
}
public static void B()
{
for (; ; )
{
Console.WriteLine("欢迎使用本程序");
Console.WriteLine("程序功能如下");
Console.WriteLine();
Console.WriteLine("【1】添加约会");
Console.WriteLine("【2】浏览约会");
Console.WriteLine("【3】搜索【输入日期以浏览所有那天的约会】");
Console.WriteLine("【0】退出程序");
Console.WriteLine();
Console.Write("选择功能:");
int G = Convert.ToInt32(Console.ReadLine());
Console.WriteLine();
switch (G)
{
case 1:
MA();
break;
case 2:
AK();
break;
case 3:
Console.WriteLine("很抱歉,暂不支持该功能!");
break;
case 0:
return;
default:
Console.WriteLine("功能选择错误,请重新输入!");
break;
}
Console.Write("\n请按[ENTER]键继续...");
Console.ReadLine();
Console.Clear();
}
}
private static void AK()
{
FileStream fs = new FileStream(@"F:\\约会管理程序.txt", FileMode.OpenOrCreate, FileAccess.Read, FileShare.Read);
StreamReader sr = new StreamReader(fs, Encoding.Default);
sr.BaseStream.Seek(0, SeekOrigin.Begin);
string MM;
MM = sr.ReadToEnd();
Console.WriteLine(MM);
fs.Close();
sr.Close();
}
public static void MA()
{
FileStream fs = new FileStream(@"F:\\约会管理程序.txt", FileMode.OpenOrCreate, FileAccess.Write, FileShare.Write);
StreamWriter sw = new StreamWriter(fs, Encoding.Default);
sw.BaseStream.Seek(0, SeekOrigin.End);
sw.WriteLine();
Console.Write("注意:日期格式为(mm-dd-yyyy)!!!\n约会的日期:");
sw.Write("约会的日期:");
DateTime J;
sw.WriteLine((J = Convert.ToDateTime(Console.ReadLine())).ToString("MM-dd-yyyy"));
Console.Write("约会的时间:");
sw.Write("约会的时间:");
sw.WriteLine(Console.ReadLine());
Console.Write("姓名:");
sw.Write("姓名:");
sw.WriteLine(Console.ReadLine());
sw.Close();
fs.Close();
}
}
新手求教,
以上,如何实现功能3
另找个C#的QQ交流群
知道的回下谢谢!