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

Event Programming Intro

Uploaded by

Trevor Beloro
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)
7 views

Event Programming Intro

Uploaded by

Trevor Beloro
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/ 22

Event-Driven

Programming in
C#
Welcome to Event-Driven Programming
02

What is Event-Driven
Programming?
Event-Driven Programming (EDP) is a
paradigm where the flow of the
program is determined by events such
as user interactions, messages from
other programs, or sensor inputs.
02

Key Concepts of EDP


•Events: Actions or occurrences that the program
reacts
•Event Handlers: Functions or methods that are
invoked in response to an event.
•Event Loop: Continuously checks for events and
dispatches them to the appropriate event
handlers.
•Asynchronous Processing: Allows handling
multiple events concurrently, improving
performance.
02

Why is EDP Important in Modern


Software Development?
•Responsiveness: Allows programs to respond immediately to user
interactions or external conditions.
•Scalability: Facilitates the development of scalable applications by
enabling components to operate independently and react to events.
•Flexibility: Makes systems more flexible and easier to maintain by
decoupling event generation and handling.
•Real-World Applications: Widely used in GUI applications, web
applications, and real-time systems.
02

Applications of Event-Driven
Programming

•Web Browsers
•Mobile Apps
•Video Games
•IoT Devices
02

Introduction to C#
•C# (pronounced "C-sharp") is a modern, object-oriented
programming language developed by Microsoft.
•Designed for building a wide range of applications that
run on the .NET framework.
•First released in 2000, C# has evolved into one of the
most popular languages for developers.
02

History and Evolution of C#

•2000: Introduction of C# as part of Microsoft’s .NET


initiative.
•2002: C# 1.0 released with the first version of .NET
Framework.
•2005: C# 2.0 introduced with features like generics,
partial classes, and anonymous methods.
•2007: C# 3.0 brought LINQ (Language Integrated Query)
and lambda expressions.
02

History and Evolution of C#


•2010: C# 4.0 added dynamic binding and
named/optional arguments.
•2012: C# 5.0 introduced asynchronous programming
with async and await.
•2017: C# 7.0 focused on performance improvements
with tuples and pattern matching.
•2019-Present: Continued evolution with C# 8.0 and
beyond, enhancing nullable reference types, async
streams, and more
02
Why Choose C# for Event-Driven
Programming?
•Built-in Support: C# is inherently designed to support
event-driven programming, especially within the .NET
framework.
•Delegates and Events: C# provides robust mechanisms
like delegates and events to handle events efficiently.
•Versatility: C# is versatile, suitable for desktop
applications, web applications, games, and mobile apps.
•Integration: Seamless integration with Windows-based
applications, making it ideal for enterprise software.
02
Basic Structure of a C# Program

•Namespace Declaration
•Class Definition
•Main Method
•Statements & Expressions
02
Basic Structure of a C# Program

•Namespace Declaration: Organizes code into


namespaces.
02
Basic Structure of a C# Program

•Class Definition: Defines a blueprint for objects.


02
Basic Structure of a C# Program

•Main Method: The entry point of the program.


02
Basic Structure of a C# Program

•Statements & Expressions: Code executed by the


program
02
Basic Structure of a C# Program
02
Strengths of C#
•Object-Oriented: Supports concepts like encapsulation,
inheritance, and polymorphism.

•Type-Safe: C# checks types at compile-time, reducing runtime


errors.

•Rich Library: Extensive .NET library provides a wide range of


functionalities.

•Cross-Platform: With .NET Core, C# can run on Windows, Linux,


and macOS.

•Community & Support: Strong community and official support


from Microsoft ensure continued growth and stability.
02

Basic Event Handling


Concepts in C#
02

Introduction to Event Handling in C#


•Event handling is a key feature of C# used in
developing interactive applications.

•Events allow a class or object to notify other classes


or objects when something of interest occurs.

•Delegates play a crucial role in event handling by


providing a reference to methods.
02

What is an Event in C#
•An event is a notification sent by an object to signal the
occurrence of an action.
02

How Are Events Related to Delegates?


•Delegates as Event Handlers: In C#, events are based on
delegates, which are type-safe pointers to methods.

•Binding Methods to Events: A delegate can be assigned to a


method, and when the event is raised, the delegate calls the
method.
02

How Are Events Related to Delegates?


•Delegates as Event Handlers: In C#, events are based on
delegates, which are type-safe pointers to methods.

•Binding Methods to Events: A delegate can be assigned to a


method, and when the event is raised, the delegate calls the
method.
02

THANK YOU!

You might also like