C# Beginner to advanced - Lesson 34 - Exception Handling (try, catch, throw and finally)

Ankpro Training
Ankpro Training
37.1 هزار بار بازدید - 8 سال پیش - Types of Errors:In programming language,
Types of Errors:
In programming language, whenever we write a piece of code, then we compile and execute. In this situation we   may have chance to get three types of errors as mentioned below:
Syntactical Error  :
   example :  “ “ , ; and wrong spelling to syntax.
Compile time Error :
    example : “ “ , ; wrong spelling to syntax and Wrong data to a variable
Run time Error :
   example : When we are trying to create object to an abstract class.

Exception Handling Mechanism :
Runtime Error is nothing but an exception.  
So if program is having some exception,  we need to handle the exception  and to do that we have Exception handling Mechansim.
Following are the exception handling mechanisms :
Logical implementation
try catch implementation      

Syntax for try catch and finally

try {
// block of code to monitor for errors
}
catch (ExcepType1 exOb) {
// handler for ExcepType1
}
catch (ExcepType2 exOb) {
// handler for ExcepType2
}...
finally {
// finally code
}

Generic and Specific Catch Block:
Catch block without Exception Class is called as Generic Catch Block.
Catch block with Exception Class is called as Specific Catch Block.


Commonly Used Exceptions:
ArrayTypeMismatchException
Type of value being stored is incompatible with the type of the array.
DivideByZeroException
Division by zero attempted.
IndexOutOfRangeException
Array index is out-of-bounds.
InvalidCastException
A runtime cast is invalid.
OutOfMemoryException
Insufficient free memory exists to continue program execution. For example, this exception will be thrown if there is not sufficient free memory to create an object via new.
OverflowException
An arithmetic overflow occurred.
NullReferenceException
An attempt was made to operate on a null reference—that is, a reference that does not refer to an object.


ankpro
ankpro training
Asp.net MVC
C#
C sharp
Bangalore
Rajajinagar
Selenium
Coded UI
Mobile automation testing
Mobile testing
JQuery
JavaScript
.Net
Components of the .Net framework
Hello World
Literal
Keywords
Variable
Data types
Operators
Branching
Loops
Arrays
ArrayList
Strings
String Builder
Structures
Enums
Functions
Classes
Inheritance
Polymorphism
Properties
Indexers
Events
Nested Classes
Delegates
Anonymous methods
Labda expressions
Abstract classes
Exception Handling
Linq
Interfaces
Extension methods
Anonymous types
Generics
Collections
Garbage Collection
Reflection
Attributes
Input and output statements
Type casting
Boxing and Unboxing
Var vs Dynamic vs Object
8 سال پیش در تاریخ 1395/01/16 منتشر شده است.
37,180 بـار بازدید شده
... بیشتر