Professional Documents
Culture Documents
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Lab2
{
class Program
{
public static void WriteData(StreamWriter sw)
{
int isbn;
string bookName;
Console.WriteLine("ISBN:");
isbn = Convert.ToInt16(Console.ReadLine());
sw.WriteLine("ISBN:\n{0}", isbn);
Console.WriteLine("Book name:");
bookName = Console.ReadLine();
sw.WriteLine("Book name:\n{0}", bookName);
sw.Close();
}
public static void ReadData(StreamReader sr)
{
Console.WriteLine("\nList of the books:");
Console.WriteLine(sr.ReadToEnd());
sr.Close();
}
public static int SizeOfTheList(StreamReader sr2)
{
int count = 0;
string readData;
do
{
readData = sr2.ReadLine();
if (readData == "ISBN:")
count++;
} while (readData != null);
sr2.Close();
return count;
}
static void Main(string[] args)
{
StreamWriter sw = new StreamWriter(@"Books.txt",true);
WriteData(sw);
}
}
}