0% found this document useful (0 votes)
16 views

Net Oops

Uploaded by

Revanth Pragada
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
16 views

Net Oops

Uploaded by

Revanth Pragada
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 20

.

NET OOPS
Agenda

● Exception Handling and Exploring Structs


● Basic Object Oriented Programming concepts
● Abstraction, Interface and Inheritance
● Delegates
● LINQ

DO NOT WRITE ANYTHING


HERE. LEAVE THIS SPACE FOR
WEBCAM
Exception Handling and Exploring Structs
Exception Handling and Exploring Structs

Exception Handling
A problem that occurs during the execution of a programme is referred to as an exception.
Example: Attempting to divide by zero.

Syntax: try
{
// Code causing exception case
} catch( ExceptionName e1 )
{
// Code to handle exception
} catch( ExceptionName e2 )
{
} catch( ExceptionName eN )
{
// Code to handle exception
} DO NOT WRITE ANYTHING
finally HERE. LEAVE THIS SPACE FOR
{ WEBCAM
// statements to be executed
}
Exception Handling and Exploring Structs

Exception Classes in C#
● System.IO.IOException
● System.IndexOutOfRangeException
● System.ArrayTypeMismatchException
● System.NullReferenceException
● System.DivideByZeroException
● System.InvalidCastException
● System.OutOfMemoryException
● System.StackOverflowException

DO NOT WRITE ANYTHING


HERE. LEAVE THIS SPACE FOR
WEBCAM
Exception Handling and Exploring Structs

Exploring Structs
● Structure is a value type data type in C#.
● It allows you to combine relevant data from several data kinds into a single variable.
● A structure is created with the struct keyword.

Example:
struct novels
{
public string title;
public string author;
public int book_id;
};

DO NOT WRITE ANYTHING


HERE. LEAVE THIS SPACE FOR
WEBCAM
Basic Object Oriented Programming Concepts
Basic Object Oriented Programming Concepts

Encapsulation
● The process of encapsulating one or more elements within a physical or logical container is
characterised as encapsulation.
● Encapsulation prohibits access to implementation details in object-oriented programming.
● An access specifier determines the scope and visibility of a class member. The following access
specifiers are supported by C#:

● Public
● Private
● Protected
● Internal
● Protected internal

DO NOT WRITE ANYTHING


HERE. LEAVE THIS SPACE FOR
WEBCAM
Basic Object Oriented Programming Concepts

Polymorphism
● Polymorphism refers to the fact that something exists in multiple forms.
● Polymorphism is commonly described in the object-oriented programming
paradigm as "one interface, numerous functions."

DO NOT WRITE ANYTHING


HERE. LEAVE THIS SPACE FOR
WEBCAM
Abstraction, Interface and Inheritance
Abstraction, Interface and Inheritance

Abstraction
Abstraction in C# refers to the technique of hiding internal details and simply displaying functionality.

Abstract Method
An abstract method is one that is declared abstract and has no body.
Example: public abstract void write ( );

Abstract Class
An abstract class is one that has been declared abstract. There are both abstract and non-abstract methods
that can be used.
It's a class that can't create new objects (to access it, it must be inherited from another class).

DO NOT WRITE ANYTHING


HERE. LEAVE THIS SPACE FOR
WEBCAM
Abstraction, Interface and Inheritance

Interface
An interface is an entirely "abstract class," having only abstract methods and properties (and no bodies)

• All the methods are only abstract methods inside an Interface


• No method body
• No instantiation

Example:
// interface
interface living beings
{
void sleep(); // interface method (does not include a body)
void eat(); // interface method (does not include a body)
}
DO NOT WRITE ANYTHING
HERE. LEAVE THIS SPACE FOR
WEBCAM
Abstraction, Interface and Inheritance

Inheritance
● In C#, inheritance refers to the ability to build a class that inherits the attributes and actions of another
class.
● Derived Class (Child) - a class that is descended from another.
● The class being inherited from is called the base class (parent).
● Use the : sign to inherit from a class.

Syntax:

<acess-specifier> class <base_class> {


...
}

class <derived_class> : <base_class> {


... DO NOT WRITE ANYTHING
} HERE. LEAVE THIS SPACE FOR
WEBCAM
Delegates and Event Handlers
Delegates and Event Handlers

Delegates
● Delegate is a reference to a method in C#. In C and C++, it works similarly to a function pointer.
● Internally, a delegate declaration specifies a class that is inherited from another class of
system.delegate
● Syntax:
delegate <return type> <delegate-name> <parameter list>

DO NOT WRITE ANYTHING


HERE. LEAVE THIS SPACE FOR
WEBCAM
Delegates and Event Handlers

Event Handlers
● The event is a delegate that has been encapsulated.
● Many people can subscribe to an event.
● In general, we utilised the Event to represent a single user activity, such as clicking a button.
● If the event has many subscribers, the event handler is called synchronously.
● Syntax:
public event EventHandler Event_Name;

DO NOT WRITE ANYTHING


HERE. LEAVE THIS SPACE FOR
WEBCAM
LINQ
LINQ
● In C#, LINQ is used to access data from a variety of sources, including objects, data sets, SQL Server, and
XML.
● LINQ is abbreviated as Language Integrated Query.

DO NOT WRITE ANYTHING


HERE. LEAVE THIS SPACE FOR
WEBCAM
Summary
● How to handle exceptions and also information about structures in C#
● Basic OOPs Concepts like Polymorphism, inheritance, abstraction, interface and encapsulation
● Creating Delegates and Event Handling
● LINQ - Language Integrated Query Structure and uses

DO NOT WRITE ANYTHING


HERE. LEAVE THIS SPACE FOR
WEBCAM
Thank You

Proprietary content. ©Great Learning. All Rights Reserved. Unauthorized use or distribution prohibited

You might also like