Tag: Example

Example of catching the OverflowException in C#

static void Main() { int IntVal = 999999; checked { try { int data = checked(IntVal * IntVal); } catch (OverflowException e) { Console.WriteLine(e); } } } Tutorials you might find interesting:REVIEW – Recover Excel Password with password-find OnlineSenthil-Kumar-B-Posted-by-Senthil-Kumar-B-August-12-2020-CSharp-3-Min-Read-Microsoft-had-released-the-preview-version-of-.NET-5-some-time-back-which-comes-with-C-9-Preview-too.-While-it-is-sti…C Program to find square and cube of given numberC Program to find the size of the arrayC Program to generate random numbers

Example of catching the NullReferenceException

public void Main() { try { int ? number = null; Console.WriteLine(number.ToString()); } catch (NullReferenceException) { MessageBox.Show(“Null Reference Exception Caught”); } } Tutorials you might find interesting:C Program to check number is perfect number or notC Program to sort the numbers in descending orderC Program to find if the given number is a Strong Number or not.C Program to sort numbers in ascending orderC Program…

Single Line and Multi Line Comment Example in C#

using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Diagnostics; using System.Drawing; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows.Forms; namespace WindowsFormsApplication1 { #region testregion public partial class Form1 : Form { // Single Line Comment Test public Form1() { InitializeComponent(); } /* This is a Multiline Comment test */ private void Form1_Load(object sender, EventArgs e) { Debug.WriteLine(“This is a test message”); } } #endregion…