SearchScore
static void Main(string[] args)
{
Console.WriteLine("請輸入要查詢的學(xué)生姓名!");
string nameToQuery = Console.ReadLine();
using (Stream stream = File.OpenRead(@"D:\C#\vs2015\SearchScore\Score.txt"))
using (StreamReader reader = new StreamReader(stream))
{
string line;
bool isFound = false;
while ((line = reader.ReadLine()) != null)
{
string[] strs = line.Split(' ');
string name = strs[0];
string score = strs[1];
if (string.IsNullOrEmpty(nameToQuery))//輸入為空,成績?nèi)枯敵?br /> {
Console.WriteLine(name + "的成績是" + score);
}
else
{
if (name == nameToQuery)
{
Console.WriteLine("成績是" + score);
isFound = true;
}
}
}
if (!string.IsNullOrEmpty(nameToQuery) && !isFound)
{
Console.WriteLine(nameToQuery +"的成績不存在!!!");
}
}
Console.ReadKey();
}
轉(zhuǎn)載于:https://www.cnblogs.com/liulida/p/7163640.html
《新程序員》:云原生和全面數(shù)字化實踐50位技術(shù)專家共同創(chuàng)作,文字、視頻、音頻交互閱讀總結(jié)
以上是生活随笔為你收集整理的SearchScore的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 基于struts2的寝室圈项目
- 下一篇: u盘拷东西拷满显示0字节要格式化怎么办