using System.Collections.Generic;
namespace SarasaviLibrarySystem
public int Id { get; set; }
public string Title { get; set; }
public string Author { get; set; }
public int Year { get; set; }
public int Id { get; set; }
public string Name { get; set; }
public string RegistrationNumber { get; set; }
static List<Book> bookList = new List<Book>();
static List<Student> studentList = new List<Student>();
static int nextBookId = 1;
static int nextStudentId = 1;
static void Main(string[] args)
Console.WriteLine("\n--- SARASAVI LIBRARY SYSTEM ---");
Console.WriteLine("1. Add Book");
Console.WriteLine("2. View All Books");
Console.WriteLine("3. Register Student");
Console.WriteLine("4. View All Students");
Console.WriteLine("5. Exit");
Console.Write("Choose an option: ");
string choice = Console.ReadLine();
Console.WriteLine("Invalid option. Try again.");
Console.Write("Enter Book Title: ");
string title = Console.ReadLine();
Console.Write("Enter Author Name: ");
string author = Console.ReadLine();
Console.Write("Enter Year Published: ");
while (!int.TryParse(Console.ReadLine(), out year))
Console.Write("Invalid year. Enter again: ");
Console.WriteLine("✅ Book added successfully!");
Console.WriteLine("No books available.");
Console.WriteLine("\n--- List of Books ---");
foreach (Book book in bookList)
Console.WriteLine($"ID: {book.Id}, Title: {book.Title}, Author: {book.Author}, Year: {book.Year}");
static void RegisterStudent()
Console.Write("Enter Student Name: ");
string name = Console.ReadLine();
Console.Write("Enter Registration Number: ");
string regNo = Console.ReadLine();
Student newStudent = new Student
RegistrationNumber = regNo
studentList.Add(newStudent);
Console.WriteLine("✅ Student registered successfully!");
static void ViewStudents()
if (studentList.Count == 0)
Console.WriteLine("No students registered.");
Console.WriteLine("\n--- List of Students ---");
foreach (Student student in studentList)
Console.WriteLine($"ID: {student.Id}, Name: {student.Name}, Reg No: {student.RegistrationNumber}");