private void btnCheckTriangleType_Click(object sender, EventArgs e) { //handle the errors and display the message properly try { lblValidationMessage.Text = ""; lblTriangleType.Text = ""; TriangleObj.SideALength = txtSideALength.Text; TriangleObj.SideBLength = txtSideBLength.Text; TriangleObj.SideCLength = txtSideCLength.Text; var ValidationMessage = TriangleObj.ValidateTriangleSideInputs(); if (!String.IsNullOrEmpty(ValidationMessage)) { lblValidationMessage.Text = ValidationMessage; } else { //Here Check For Triangle Type var TriangleTypeString = TriangleObj.CalculateTriangleType(Convert.ToInt16(TriangleObj.SideALength), Convert.ToInt16(TriangleObj.SideBLength), Convert.ToInt16(TriangleObj.SideCLength)); lblTriangleType.Text = "This is " + TriangleTypeString + " triangle"; } } catch (Exception ex) // here shows the exception message thrown if any validation error is there { MessageBox.Show(ex.Message.ToString()); } }