SlideShare a Scribd company logo
1 of 20
Created By-

PRANAB BHATTACHARYA
MCA-TY
Roll no. : 14
 Overview
 Classes and objects

Class members

Methods

Constructors

Destructors

Nested Classes

Access Modifiers and Access levels

Static (Shared) Classes and Members

Anonymous types
 Inheritance

Overriding members
• Sealed and Abstract classes
 Interfaces
1
o .NET

Framework languages provide full support for
Object-oriented programming
o Encapsulation, Inheritance, Polymorphism
o Encapsulation means that a group of related
properties, methods, and other members are treated as a
single unit or object.
o Inheritance describes the ability to create new
classes based on an existing class.
o Polymorphism means that you can have multiple
classes that can be used interchangeably, even though
each class implements the same properties or methods
in different ways.

2
o Classes describe the type of objects…
o …while objects are usable instances of classes.
o Using the blueprint analogy, a class is a
blueprint, and an object is a building made from
that blueprint.
To define a class and object:
class SampleClass
{
}
SampleClass SC1 = new SampleClass();
3
o A method is an action that an object can perform.
To define a method of a class:
class SampleClass
{
public int sampleMethod(string sampleParam)
{
// Insert code here
}
}
4
o A class can have several implementations, or
overloads, of the same method that differ in the
number of parameters or parameter types.
oTo overload a method:
public int sampleMethod(string sampleParam) {};
public int sampleMethod(int sampleParam) {}
Public int sampleMethod(int param1,int param2){};
o In most cases you declare a method within a class
definition. However, both Visual Basic and C# also
support extension methods that allow you to add
methods to an existing class outside the actual

5
o Constructors are class methods that are executed
automatically when an object of a given type is created. (Run
before any other code)
o Constructors usually Initialize the data members.
oSupport Overloading.

To define a constructor for a class:
public class SampleClass
{
int I;
public SampleClass()
{
I = 1;
}

6
o Destructors are used to destruct instances of classes.
o In the .NET Framework, the garbage collector
automatically manages the allocation and release of
memory for the managed objects in your application.
o Destructors are still needed to clean up any
unmanaged resources that your application creates.
o There can be only one destructor for a class.
7
o A class defined within another class is called nested.
(Default - private)
class Container
{
class Nested
{
// Add code here.
}
}

o To create an instance of the nested class, use the name
of the container class followed by the dot and then
followed by the name of the nested class:
Container.Nested nestedInstance = new

8
o All classes and class members can specify what access level
they provide to other classes by using access modifiers.
The following access modifiers are available:
C# Modifier
Definition
___________________________________________________
Public
The type or member can be accessed by any other
code in
the same assembly or another assembly that
references it.
Private
The type or member can only be accessed by code
in the
same class.
Protected The type or member can only be accessed by code
in the
same class or in a derived class.
Internal
The type or member can be accessed by any
code in the

9
o A static member of the class is a
property, procedure, or field that is shared by all
instances of a class.
o To define a static (shared) member:
static class SampleClass
{
public static string SampleString = "Sample
String";
}

10
o To access the static member, use the name of the
class without creating an object of this class:
Console.WriteLine(SampleClass.SampleStrin
g);
o Static (shared) classes in C# have static (shared)
members only and cannot be instantiated.
o Static (shared) members also cannot access nonstatic (non-shared) properties, fields or methods
11
o Enable you to create objects without writing a class
definition for the data type. (compiler generates a
class)
oThe class has no usable name and contains the
properties you specify in declaring the object.
o To create an instance of an anonymous type:
// sampleObject is an instance of a simple anonymous
type.
var sampleObject =
new { FirstProperty = "A", SecondProperty = "B" };

12
o Creates a new class that reuses, extends, and modifies
the behavior that is defined in another class.
Base Class
– The class whose members are
inherited
Derived Class – The class that inherits those
members.
o In C#, all classes implicitely inherit from the Object
class.
* .NET Framework doesn’t support MULTIPLE
INHERITANCE i.e. One derived class can not have more
than One base class
Syntax :

13
o By default all classes can be inherited.
o We can specify whether a class must not be used as a
base class, or create a class that can be used as a base
class only.
To specify that a class cannot be used as a base class:
public sealed class A { }

 To specify that a class can be used as a base class
only and cannot be instantiated :
public abstract class B { }

14
o By default, a derived class inherits all members
from its base class.
oyou want to change the behavior of the inherited
member, you need to override it
oWhat is Overriding ??
-> Overriding is defining a new implementation of a
method, property or event in the derived class.
15
Overriding modifiers..
C# Modifier
Definition
virtual (C# Reference) - Allows a class member to be
overridden in a derived class.
override (C# Reference) - Overrides a virtual
(overridable) member defined in the base class.
abstract (C# Reference) - Requires that a class member
to be overridden in the derived class.

16
o Interfaces, like classes, define a set of
properties, methods, and events.
o But unlike classes, interfaces do not provide
implementation.
oThey are implemented by classes, and defined
as separate entities from classes.

oAn interface represents a contract, in that a
class that implements an interface must
implement every aspect of that interface exactly

17
o To define an interface:
interface ISampleInterface
{
void doSomething();
}

o To implement an interface in a class:
class SampleClass : ISampleInterface
{
void ISampleInterface.doSomething()
{
// Method implementation.
}
}

18
19

More Related Content

What's hot

Oops concepts || Object Oriented Programming Concepts in Java
Oops concepts || Object Oriented Programming Concepts in JavaOops concepts || Object Oriented Programming Concepts in Java
Oops concepts || Object Oriented Programming Concepts in JavaMadishetty Prathibha
 
Collections Framework
Collections FrameworkCollections Framework
Collections FrameworkSunil OS
 
Inheritance in JAVA PPT
Inheritance  in JAVA PPTInheritance  in JAVA PPT
Inheritance in JAVA PPTPooja Jaiswal
 
Java abstract class & abstract methods
Java abstract class & abstract methodsJava abstract class & abstract methods
Java abstract class & abstract methodsShubham Dwivedi
 
L9 wrapper classes
L9 wrapper classesL9 wrapper classes
L9 wrapper classesteach4uin
 
11 constructors in derived classes
11 constructors in derived classes11 constructors in derived classes
11 constructors in derived classesDocent Education
 
Static Data Members and Member Functions
Static Data Members and Member FunctionsStatic Data Members and Member Functions
Static Data Members and Member FunctionsMOHIT AGARWAL
 
Chapter 02: Classes Objects and Methods Java by Tushar B Kute
Chapter 02: Classes Objects and Methods Java by Tushar B KuteChapter 02: Classes Objects and Methods Java by Tushar B Kute
Chapter 02: Classes Objects and Methods Java by Tushar B KuteTushar B Kute
 

What's hot (20)

Oops concepts || Object Oriented Programming Concepts in Java
Oops concepts || Object Oriented Programming Concepts in JavaOops concepts || Object Oriented Programming Concepts in Java
Oops concepts || Object Oriented Programming Concepts in Java
 
Inheritance In Java
Inheritance In JavaInheritance In Java
Inheritance In Java
 
Wrapper class
Wrapper classWrapper class
Wrapper class
 
Inheritance In Java
Inheritance In JavaInheritance In Java
Inheritance In Java
 
Collections Framework
Collections FrameworkCollections Framework
Collections Framework
 
Inheritance in JAVA PPT
Inheritance  in JAVA PPTInheritance  in JAVA PPT
Inheritance in JAVA PPT
 
Java abstract class & abstract methods
Java abstract class & abstract methodsJava abstract class & abstract methods
Java abstract class & abstract methods
 
C# basics
 C# basics C# basics
C# basics
 
Inheritance C#
Inheritance C#Inheritance C#
Inheritance C#
 
OOPS Basics With Example
OOPS Basics With ExampleOOPS Basics With Example
OOPS Basics With Example
 
L9 wrapper classes
L9 wrapper classesL9 wrapper classes
L9 wrapper classes
 
11 constructors in derived classes
11 constructors in derived classes11 constructors in derived classes
11 constructors in derived classes
 
JAVA OOP
JAVA OOPJAVA OOP
JAVA OOP
 
Static Data Members and Member Functions
Static Data Members and Member FunctionsStatic Data Members and Member Functions
Static Data Members and Member Functions
 
C# Access modifiers
C# Access modifiersC# Access modifiers
C# Access modifiers
 
Constructors in C++
Constructors in C++Constructors in C++
Constructors in C++
 
C# Inheritance
C# InheritanceC# Inheritance
C# Inheritance
 
Chapter 02: Classes Objects and Methods Java by Tushar B Kute
Chapter 02: Classes Objects and Methods Java by Tushar B KuteChapter 02: Classes Objects and Methods Java by Tushar B Kute
Chapter 02: Classes Objects and Methods Java by Tushar B Kute
 
polymorphism
polymorphism polymorphism
polymorphism
 
Java Basic Oops Concept
Java Basic Oops ConceptJava Basic Oops Concept
Java Basic Oops Concept
 

Similar to Object Oriented Programming with C#

Similar to Object Oriented Programming with C# (20)

C# classes objects
C#  classes objectsC#  classes objects
C# classes objects
 
Question and answer Programming
Question and answer ProgrammingQuestion and answer Programming
Question and answer Programming
 
Object and Classes in Java
Object and Classes in JavaObject and Classes in Java
Object and Classes in Java
 
Oops
OopsOops
Oops
 
Java basics
Java basicsJava basics
Java basics
 
Abstraction in java [abstract classes and Interfaces
Abstraction in java [abstract classes and InterfacesAbstraction in java [abstract classes and Interfaces
Abstraction in java [abstract classes and Interfaces
 
C# program structure
C# program structureC# program structure
C# program structure
 
python.pptx
python.pptxpython.pptx
python.pptx
 
‫Object Oriented Programming_Lecture 3
‫Object Oriented Programming_Lecture 3‫Object Oriented Programming_Lecture 3
‫Object Oriented Programming_Lecture 3
 
Lecture 9
Lecture 9Lecture 9
Lecture 9
 
Unit3 part1-class
Unit3 part1-classUnit3 part1-class
Unit3 part1-class
 
Java chapter 5
Java chapter 5Java chapter 5
Java chapter 5
 
Ch-2ppt.pptx
Ch-2ppt.pptxCh-2ppt.pptx
Ch-2ppt.pptx
 
Java 06
Java 06Java 06
Java 06
 
9781439035665 ppt ch10
9781439035665 ppt ch109781439035665 ppt ch10
9781439035665 ppt ch10
 
Lesson 13 object and class
Lesson 13 object and classLesson 13 object and class
Lesson 13 object and class
 
Learn C# Programming - Classes & Inheritance
Learn C# Programming - Classes & InheritanceLearn C# Programming - Classes & Inheritance
Learn C# Programming - Classes & Inheritance
 
Inheritance in java.ppt
Inheritance in java.pptInheritance in java.ppt
Inheritance in java.ppt
 
oops-123991513147-phpapp02.pdf
oops-123991513147-phpapp02.pdfoops-123991513147-phpapp02.pdf
oops-123991513147-phpapp02.pdf
 
Opp concept in c++
Opp concept in c++Opp concept in c++
Opp concept in c++
 

Recently uploaded

Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsRizwan Syed
 
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Mark Simos
 
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...shyamraj55
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupFlorian Wilhelm
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfAddepto
 
Bluetooth Controlled Car with Arduino.pdf
Bluetooth Controlled Car with Arduino.pdfBluetooth Controlled Car with Arduino.pdf
Bluetooth Controlled Car with Arduino.pdfngoud9212
 
Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfAlex Barbosa Coqueiro
 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebUiPathCommunity
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesSinan KOZAK
 
Vertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsVertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsMiki Katsuragi
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationRidwan Fadjar
 
Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Scott Keck-Warren
 
Key Features Of Token Development (1).pptx
Key  Features Of Token  Development (1).pptxKey  Features Of Token  Development (1).pptx
Key Features Of Token Development (1).pptxLBM Solutions
 
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 3652toLead Limited
 
Artificial intelligence in the post-deep learning era
Artificial intelligence in the post-deep learning eraArtificial intelligence in the post-deep learning era
Artificial intelligence in the post-deep learning eraDeakin University
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii SoldatenkoFwdays
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):comworks
 
Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Enterprise Knowledge
 

Recently uploaded (20)

Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL Certs
 
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
 
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptxE-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
 
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project Setup
 
Hot Sexy call girls in Panjabi Bagh 🔝 9953056974 🔝 Delhi escort Service
Hot Sexy call girls in Panjabi Bagh 🔝 9953056974 🔝 Delhi escort ServiceHot Sexy call girls in Panjabi Bagh 🔝 9953056974 🔝 Delhi escort Service
Hot Sexy call girls in Panjabi Bagh 🔝 9953056974 🔝 Delhi escort Service
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdf
 
Bluetooth Controlled Car with Arduino.pdf
Bluetooth Controlled Car with Arduino.pdfBluetooth Controlled Car with Arduino.pdf
Bluetooth Controlled Car with Arduino.pdf
 
Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdf
 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio Web
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen Frames
 
Vertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsVertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering Tips
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 Presentation
 
Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024
 
Key Features Of Token Development (1).pptx
Key  Features Of Token  Development (1).pptxKey  Features Of Token  Development (1).pptx
Key Features Of Token Development (1).pptx
 
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
 
Artificial intelligence in the post-deep learning era
Artificial intelligence in the post-deep learning eraArtificial intelligence in the post-deep learning era
Artificial intelligence in the post-deep learning era
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):
 
Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024
 

Object Oriented Programming with C#

  • 2.  Overview  Classes and objects  Class members  Methods  Constructors  Destructors  Nested Classes  Access Modifiers and Access levels  Static (Shared) Classes and Members  Anonymous types  Inheritance  Overriding members • Sealed and Abstract classes  Interfaces 1
  • 3. o .NET Framework languages provide full support for Object-oriented programming o Encapsulation, Inheritance, Polymorphism o Encapsulation means that a group of related properties, methods, and other members are treated as a single unit or object. o Inheritance describes the ability to create new classes based on an existing class. o Polymorphism means that you can have multiple classes that can be used interchangeably, even though each class implements the same properties or methods in different ways. 2
  • 4. o Classes describe the type of objects… o …while objects are usable instances of classes. o Using the blueprint analogy, a class is a blueprint, and an object is a building made from that blueprint. To define a class and object: class SampleClass { } SampleClass SC1 = new SampleClass(); 3
  • 5. o A method is an action that an object can perform. To define a method of a class: class SampleClass { public int sampleMethod(string sampleParam) { // Insert code here } } 4
  • 6. o A class can have several implementations, or overloads, of the same method that differ in the number of parameters or parameter types. oTo overload a method: public int sampleMethod(string sampleParam) {}; public int sampleMethod(int sampleParam) {} Public int sampleMethod(int param1,int param2){}; o In most cases you declare a method within a class definition. However, both Visual Basic and C# also support extension methods that allow you to add methods to an existing class outside the actual 5
  • 7. o Constructors are class methods that are executed automatically when an object of a given type is created. (Run before any other code) o Constructors usually Initialize the data members. oSupport Overloading. To define a constructor for a class: public class SampleClass { int I; public SampleClass() { I = 1; } 6
  • 8. o Destructors are used to destruct instances of classes. o In the .NET Framework, the garbage collector automatically manages the allocation and release of memory for the managed objects in your application. o Destructors are still needed to clean up any unmanaged resources that your application creates. o There can be only one destructor for a class. 7
  • 9. o A class defined within another class is called nested. (Default - private) class Container { class Nested { // Add code here. } } o To create an instance of the nested class, use the name of the container class followed by the dot and then followed by the name of the nested class: Container.Nested nestedInstance = new 8
  • 10. o All classes and class members can specify what access level they provide to other classes by using access modifiers. The following access modifiers are available: C# Modifier Definition ___________________________________________________ Public The type or member can be accessed by any other code in the same assembly or another assembly that references it. Private The type or member can only be accessed by code in the same class. Protected The type or member can only be accessed by code in the same class or in a derived class. Internal The type or member can be accessed by any code in the 9
  • 11. o A static member of the class is a property, procedure, or field that is shared by all instances of a class. o To define a static (shared) member: static class SampleClass { public static string SampleString = "Sample String"; } 10
  • 12. o To access the static member, use the name of the class without creating an object of this class: Console.WriteLine(SampleClass.SampleStrin g); o Static (shared) classes in C# have static (shared) members only and cannot be instantiated. o Static (shared) members also cannot access nonstatic (non-shared) properties, fields or methods 11
  • 13. o Enable you to create objects without writing a class definition for the data type. (compiler generates a class) oThe class has no usable name and contains the properties you specify in declaring the object. o To create an instance of an anonymous type: // sampleObject is an instance of a simple anonymous type. var sampleObject = new { FirstProperty = "A", SecondProperty = "B" }; 12
  • 14. o Creates a new class that reuses, extends, and modifies the behavior that is defined in another class. Base Class – The class whose members are inherited Derived Class – The class that inherits those members. o In C#, all classes implicitely inherit from the Object class. * .NET Framework doesn’t support MULTIPLE INHERITANCE i.e. One derived class can not have more than One base class Syntax : 13
  • 15. o By default all classes can be inherited. o We can specify whether a class must not be used as a base class, or create a class that can be used as a base class only. To specify that a class cannot be used as a base class: public sealed class A { }  To specify that a class can be used as a base class only and cannot be instantiated : public abstract class B { } 14
  • 16. o By default, a derived class inherits all members from its base class. oyou want to change the behavior of the inherited member, you need to override it oWhat is Overriding ?? -> Overriding is defining a new implementation of a method, property or event in the derived class. 15
  • 17. Overriding modifiers.. C# Modifier Definition virtual (C# Reference) - Allows a class member to be overridden in a derived class. override (C# Reference) - Overrides a virtual (overridable) member defined in the base class. abstract (C# Reference) - Requires that a class member to be overridden in the derived class. 16
  • 18. o Interfaces, like classes, define a set of properties, methods, and events. o But unlike classes, interfaces do not provide implementation. oThey are implemented by classes, and defined as separate entities from classes. oAn interface represents a contract, in that a class that implements an interface must implement every aspect of that interface exactly 17
  • 19. o To define an interface: interface ISampleInterface { void doSomething(); } o To implement an interface in a class: class SampleClass : ISampleInterface { void ISampleInterface.doSomething() { // Method implementation. } } 18
  • 20. 19