Indexer AKEEL AHMED.

Slides:



Advertisements
Similar presentations
Chapter 17 Failures and exceptions. This chapter discusses n Failure. n The meaning of system failure. n Causes of failure. n Handling failure. n Exception.
Advertisements

C++ Programming: Program Design Including Data Structures, Fourth Edition Chapter 15: Exception Handling.
Objectives In this chapter you will: Learn what an exception is Learn how to handle exceptions within a program See how a try / catch block is used to.
C++ Programming: From Problem Analysis to Program Design, Third Edition Chapter 16: Exception Handling.
Slides prepared by Rose Williams, Binghamton University ICS201 Exception Handling University of Hail College of Computer Science and Engineering Department.
Road Map Introduction to object oriented programming. Classes
Liang, Introduction to Java Programming, Fifth Edition, (c) 2005 Pearson Education, Inc. All rights reserved Chapter 17 Exceptions and.
1 Chapter 4 Language Fundamentals. 2 Identifiers Program parts such as packages, classes, and class members have names, which are formally known as identifiers.
Exception Handling An Exception is an indication of a problem that occurs during a program’s execution. Exception handling enables the programmer to create.
Chapter 15 Strings String::Concat String::CompareTo, Equals, == If( string1 == S”Hello”) String1->Equals(S”Hello”) String1->CompareTo(S”Hello”) CompareTo.
Java Review 2 – Errors, Exceptions, Debugging Nelson Padua-Perez Chau-Wen Tseng Department of Computer Science University of Maryland, College Park.
Introduction to Java Chapter 11 Error Handling. Motivations When a program runs into a runtime error, the program terminates abnormally. How can you handle.
Ranga Rodrigo. Class is central to object oriented programming.
What is an exception? An exception is: – an event that interrupts the normal processing of the program. –an error condition that violates the semantic.
Java Programming Exceptions Handling. Topics: Learn about exceptions Try code and catch Exceptions Use the Exception getMessage() method Throw and catch.
CIS 270—Application Development II Chapter 13—Exception Handling.
And other languages…. must remember to check return value OR, must pass label/exception handler to every function Caller Function return status Caller.
1 CSC241: Object Oriented Programming Lecture No 27.
220 FINAL TEST REVIEW SESSION Omar Abdelwahab. INHERITANCE AND POLYMORPHISM Suppose you have a class FunClass with public methods show, tell, and smile.
Lecture 8 Inheritance Richard Gesick. 2 OBJECTIVES How inheritance promotes software reusability. The concepts of base classes and derived classes. To.
CSM-Java Programming-I Spring,2005 Objects and Classes Overview Lesson - 1.
1 Web-Enabled Decision Support Systems Objects and Procedures Don McLaughlin IE 423 Design of Decision Support Systems (304)
PROGRAMMING IN VISUAL BASIC.NET VISUAL BASIC BUILDING BLOCKS Bilal Munir Mughal 1 Chapter-5.
The Java Programming Language
Exceptions Handling Exceptionally Sticky Problems.
Introduction to Exception Handling and Defensive Programming.
Data Structures Using Java1 Chapter 2 Inheritance and Exception Handling.
FT228/3 Web Development Error processing. Introduction READ Chapter 9 of Java Server Pages from O’reilly 2 nd Edition Need to be able to 1) Diagnose and.
Exceptions, handling exceptions & message boxes Year 11 Information Technology.
Exceptions in C++. Exceptions  Exceptions provide a way to handle the errors generated by our programs by transferring control to functions called handlers.
Exceptions and Assertions Chapter 15 – CSCI 1302.
 In the java programming language, a keyword is one of 50 reserved words which have a predefined meaning in the language; because of this,
CS212: Object Oriented Analysis and Design Lecture 19: Exception Handling.
Classes, Interfaces and Packages
CIS 200 Test 01 Review. Built-In Types Properties  Exposed “Variables” or accessible values of an object  Can have access controlled via scope modifiers.
1 Exceptions. 2 Syntax Errors, Runtime Errors, and Logic Errors syntax errors, runtime errors, and logic errors You learned that there are three categories.
Object orientation and Packaging in Java Object Orientation and Packaging Introduction: After completing this chapter, you will be able to identify.
© 2006 Pearson Addison-Wesley. All rights reserved 1-1 Chapter 1 Review of Java Fundamentals.
CMSC 202 Computer Science II for Majors. CMSC 202UMBC Topics Exceptions Exception handling.
Exceptions Lecture 11 COMP 401, Fall /25/2014.
Lecture10 Exception Handling Jaeki Song. Introduction Categories of errors –Compilation error The rules of language have not been followed –Runtime error.
C# Fundamentals An Introduction. Before we begin How to get started writing C# – Quick tour of the dev. Environment – The current C# version is 5.0 –
And other languages…. must remember to check return value OR, must pass label/exception handler to every function Caller Function return status Caller.
Exception. Agenda Exception. Handling Exceptions. The finally Clause.
CSE 332: C++ Exceptions Motivation for C++ Exceptions Void Number:: operator/= (const double denom) { if (denom == 0.0) { // what to do here? } m_value.
Java Exceptions a quick review….
C++ Exceptions.
Andy Wang Object Oriented Programming in C++ COP 3330
CIS 200 Test 01 Review.
OBJECT ORIENTED PROGRAMMING II LECTURE 10 GEORGE KOUTSOGIANNAKIS
Handling Exceptionally Sticky Problems
Chapter 14: Exception Handling
Lecture 23 Polymorphism Richard Gesick.
Arrays, For loop While loop Do while loop
Exception Handling Chapter 9.
Lecture 22 Inheritance Richard Gesick.
Chapter 12 Exception Handling
Exception Handling Chapter 9 Edited by JJ.
Andy Wang Object Oriented Programming in C++ COP 3330
Part B – Structured Exception Handling
Sridhar Narayan Java Basics Sridhar Narayan
Exception Handling Imran Rashid CTO at ManiWeber Technologies.
Lecture 11 Objectives Learn what an exception is.
CIS 199 Final Review.
Errors and Exceptions Error Errors are the wrongs that can make a program to go wrong. An error may produce an incorrect output or may terminate the execution.
Introduction to Programming
Handling Exceptionally Sticky Problems
Exception Handling.
Java Programming: From Problem Analysis to Program Design, 4e
A type is a collection of values
Presentation transcript:

Indexer AKEEL AHMED

Overview Indexers Enums Exception Handling What is Attribute?

Indexer Indexers allow your class to be used just like an array. Indexer an object to be indexed in the same way as an array. Indexer modifier can be private, public, protected or internal. The return type can be any valid C# types. Indexers in C# must have at least one parameter. Else the compiler will generate a compilation error.

Indexer(Example)

Indexer(Example)

Enums Enums are known as named constants.. They are essentially unique types that allow you to assign symbolic names to integral values. Enums are strongly-typed constants that makes the code more readable and less prone to errors Default data type of an enum is an integer. If we assign an integer value to an enum variable then the next variable will contain a value just greater than 1 from the previous value.

Enums(Example)

Enums(Example) Assign value to enum member.

Enums(Example) Change the default type of enum.

Exception Handling NET provides a structured way of handling the runtime errors. Business logic and error handling code is separate. The errors that occur during the execution of a program are called the runtime errors or the exceptions. Exception handling mechanism provides a way to respond to the run time errors in the program by transferring control to special code called handler. Example (Division by 0, Stack overflow, invalid type casting)

Object-Oriented way of error handling Classes to handle different types of errors. FileNotFoundException class to represent, if the file not found. IOException class to represent, if the file is already open. SecurityException class to represent, if the caller does not have permission to access the file. Easy to program and extend

try/catch Blocks When exceptions are thrown, you need to be able to handle them. This is done by implementing a try/catch block

Finally Blocks finally block will be executed before control leaves the method.

What is Attribute? Attribute is a class used to give additional declarative information for the class, method, property, indexer, etc. By using attributes you can identify the behavior of the class, method, property, indexer, etc. Syntax: [ Attribute_Name(argument(s))] The following are the different types of attributes in C#: Obsolete Conditional WebMethod DllImport

Obsolete: It is used to specify whether the class or method is deprecated or not. Obsolete attribute contains the following two arguments: i) Message ii) True/False If value is false, when deprecated method is used in the program then the program will execute with. If value is True, when deprecated method is used in application then compilation error will be displayed.

Obsolete:

User defined Attributes User defined attribute can be used to give information about the class or method i.e whether the class is user defined class or abstract class, base class, etc. For method you can specify whether it is user defined method, abstract method, virtual method, etc. Attribute class in System namespace is a base class for custom attribute or user defined attribute.

User defined Attributes

Refrence http://www.c-sharpcorner.com/UploadFile/f0b2ed/understanding-enums-constants-in-C-Sharp/