public static void AddStudentPL() { try { Student objStudent = new Student(); Console.WriteLine("Enter the Student ID :"); bool chkid; int sid; //Use TryParse to chk if the entered value is parseable or not chkid = Int32.TryParse(Console.ReadLine(), out sid); //If the Parsing fails, throw the Exception if (!chkid) { throw new StudentException("Invalid Entry"); } // If the Parsing is successful, store the StudentId into the Entity object else { objStudent.StudentId = sid; } Console.WriteLine("Enter Student Name:"); objStudent.StudentName = Console.ReadLine(); Console.WriteLine("Enter the Grade only in Uppercase:"); char Grade = Convert.ToChar(Console.ReadLine()); StudentBLL bllobj = new StudentBLL(); if (bllobj.AddStudentBL(objStudent) == false) { throw new StudentException("Student Record could not be added"); } else { Console.WriteLine("Student Details Added Successfully"); } } catch (StudentException e) { Console.WriteLine("Error occurred " + e.Message); } }