Programming Hub C,C++,C#,Asp.Net,Ado.Net,Java,  HTML,SQL.

This Blog Post Only Education Purpose For All Education Related Blogs and Articles Post Here.Download Free Software and Study Materials Mores..

Thursday, 24 July 2014

Exceptions in C#? example?

Exceptions in C#? example?
Error Types:
*      Syntax Error:-Compile type error is syntax error.
*      Exception error:-Run time error is exception error.
*      Logical error:-If you mistake in program as like not put the correct logic then show error is called logical error.
        “A logical error occurs when an application compiles and runs properly but does not produce the expected result.”
Exception:
Ø  “An exception is termed as an abnormal condition by an application during its exception.”
Ø  An Exception is an error that occurs during program execution exceptional situations arises when an operation can’t be completed normally.
Ø  When an exception occurs in and application the system throws an error.
Ø  All exception are predefined exception
Categorized of exception:
Ø System.Exception
Ø Pre-Defined for use:
System.SystemException
Ø  User Defined for Use:
                    System.SystemApplicationException

Ø  An Exception handling is the process of providing an alternative path of execution of program, when the application is unable to execute as desired.


Example:
     System.IO.IOException exception is thrown when you try to access an illegal stream object.
ü If the denominator is zero , an integer division operation throws the
“System. DivideByZeroException” exception.

using System;
using System.Collections.Generic;
using System.Text;

namespace Exception2
{
    class Test
    {
        static int Zero = 0;
        static void AFunction()
        {
            try
            {
                int j = 22 / Zero;
            }
            // this exception doesn't match
            catch (DivideByZeroException e)
            {
                Console.WriteLine(e.Message);
            }
            Console.WriteLine("In AFunction()");
        }
        //class Program
        //{
        public static void Main()
        {
            try
            {
                AFunction();
            }
            // this exception doesn't match
            catch (ArgumentException e)
            {
                Console.WriteLine("ArgumentException {0}", e);
            }
            Console.ReadKey();
        }
        //}
    }
}

See
 Output below here…

















SO Friends these are few Blogs that will help you in “Exceptions in C# ? example ?" next time i will put some more interesting Blogs thank you.. I Hope Helpful u... Enjoy :).Krishna Singh



No comments:

Post a Comment

Please Comment Your Valuable Feedback....

You Might Also Like

Developing Data-Centric Windows Applications using Java

Developing Data-Centric Windows Applications using Java Introduction The Core Java Programming and JDBC course provides an introd...

Unlimited Reseller Hosting