Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.
Getting Dirty – Part 2
Jamshid Hashimi, CodeWeekend
Agenda
• Structs
• Interfaces
• Introduction to Delegates and Events
• Introduction to Exception Handling
• Static Propert...
Structs
• Struct is a value type
• Classes are reference types
• Structs can’t have destructors, classes do.
• The power o...
Interfaces
• An interface looks like a class, but has no implementation.
• It contains declarations of:
• Events, methods,...
Delegates and Events
• Delegates are just function pointers, That is, they hold references to
functions.
• Delegation is w...
Delegates and Events
• Events are variables of type delegates.
• Events are user actions such as key press, clicks, mouse ...
Introduction to Exception Handling
• Exceptions are unforeseen errors happen in your programs.
• There are times where you...
Static Properties & Methods
• When you declare an object instance of a class, the object
instantiates its own instances of...
Attributes
• Attributes are elements that allow you to add declarative information
to your programs.
Enums
• If you have a number of constants that are logically related to each
other, then you can group together these cons...
Overloading Operators
• You can redefine or overload most of the built-in operators available
in C#.
• Operator overloadin...
Generics
• Generics allow you to delay the specification of the data type of
programming elements in a class or a method, ...
Source Codes:
http://www.facebook.com/groups/CodeWeekend
Thank You!
Upcoming SlideShare
Loading in …5
×

Week 2: Getting Dirty – Part 2

607 views

Published on

In this presentation, the most important object oriented topics and features of C# is discussed. The session was presented in 42nd Session of CodeWeekend and it is the 3rd week of C# + CS50 Series of Training.

Published in: Software
  • Be the first to comment

Week 2: Getting Dirty – Part 2

  1. 1. Getting Dirty – Part 2 Jamshid Hashimi, CodeWeekend
  2. 2. Agenda • Structs • Interfaces • Introduction to Delegates and Events • Introduction to Exception Handling • Static Properties & Methods • Using Attributes • Enums • Overloading Operators • Introduction to Generic
  3. 3. Structs • Struct is a value type • Classes are reference types • Structs can’t have destructors, classes do. • The power of objects lies in their ability to mimic real-world behavior, through inheritance and polymorphism. • Supports interface inheritance • Structs are best used for storing data, but the lack of inheritance and references can be a serious limitation.
  4. 4. Interfaces • An interface looks like a class, but has no implementation. • It contains declarations of: • Events, methods, properties.. • Inherited by classes and structs • Interfaces can inherit other interfaces
  5. 5. Delegates and Events • Delegates are just function pointers, That is, they hold references to functions. • Delegation is when you request a service by making a method call to service provider. • The service provider then reroutes this service request to another method, which services the request. • The delegate class can examine the service request and dynamically determines at runtime where to route the request. • Example: A manager receives a service request, she often delegates it to a member of her department.
  6. 6. Delegates and Events • Events are variables of type delegates. • Events are user actions such as key press, clicks, mouse movements, etc., or some occurrence such as system generated notifcations. • Applications built with the .NET Framework are object-oriented, event-driven programs. • In Windows Applications, the user interacting with a GUI usually initiates the event. • A security class could broadcast an event message when an invalid login is detected. • You can subscribe to external events.
  7. 7. Introduction to Exception Handling • Exceptions are unforeseen errors happen in your programs. • There are times where you don’t know if an error will happen • I/O error • Run out of system memory • Database and more • You want to deal with them and this where Exception Handling comes in.
  8. 8. Static Properties & Methods • When you declare an object instance of a class, the object instantiates its own instances of the properties and methods of the class it implements. • However, sometimes you may want different object instances of a class to access the same, shared variables.
  9. 9. Attributes • Attributes are elements that allow you to add declarative information to your programs.
  10. 10. Enums • If you have a number of constants that are logically related to each other, then you can group together these constants in an enumeration. • Enums are strongly typed constants which makes the code more readable and less prone to errors. • You can specify another integral numeric type by using a colon. • Enum allows us to create a new data type.
  11. 11. Overloading Operators • You can redefine or overload most of the built-in operators available in C#. • Operator overloading provides a much natural abstraction for the types. • Overloaded operators are functions with special names the keyword operator followed by the symbol for the operator being defined.
  12. 12. Generics • Generics allow you to delay the specification of the data type of programming elements in a class or a method, until it is actually used in the program • Generics allow you to write a class or method that can work with any data type. • Features • It helps you to maximize code reuse, type safety, and performance. • You can create your own generic interfaces, classes, methods, events, and delegates. • And more..
  13. 13. Source Codes: http://www.facebook.com/groups/CodeWeekend
  14. 14. Thank You!

×