0% found this document useful (0 votes)
11 views37 pages

05 Abstract Class, Method, Data Types (Var, Dyna, Nullable)

c# tutorial

Uploaded by

Tanjim Ibrahim
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)
11 views37 pages

05 Abstract Class, Method, Data Types (Var, Dyna, Nullable)

c# tutorial

Uploaded by

Tanjim Ibrahim
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/ 37

Abstraction

Course Code: CSC 2210 Course Title: Object Oriented Programming 2

Dept. of Computer Science


Faculty of Science and Technology

Lecturer No: 06 Week No: 06 Semester: Summer 2019-2020


Lecturer:
Topics

1. Abstract Types
2. Abstract Method
3. Nullable Type
Abstraction

Abstraction is a principle of object-oriented programming


and it is used to hide the implementation details and
display only essential features of the object.
Abstract Classes and Methods
Data abstraction is the process of hiding certain details and
showing only essential information to the user.
Abstraction can be achieved with either abstract classes or
interfaces
The abstract keyword is used for classes and methods:
•Abstract class: is a restricted class that cannot be used to
create objects (to access it, it must be inherited from another
class).

•Abstract method: can only be used in an abstract class, and it


does not have a body. The body is provided by the derived class
(inherited from).
To access the abstract class, it must be inherited from another class.
class Program { static void Main(string[] args) {
Pig myPig = new Pig(); // Create a Pig object
myPig.animalSound(); // Call the abstract method
myPig.sleepa(); // Call the regular method } }
In the above program we can call the method of the abstract class
mcn with the help of an object of the mcn1 class which inherits
from the class mcn.
• The virtual keyword in C# is used to override
the base class member in its derived class
based on the requirement

public class X
{
public virtual void A()
{
}
}
public class Y : X
{
public override void A()
{
base.A();
}
}
Thank You
Books

• C# 4.0 The Complete Reference; Herbert Schildt; McGraw-Hill Osborne Media; 2010
• Head First C# by Andrew Stellman
• Fundamentals of Computer Programming with CSharp – Nakov v2013
References

MSDN Library; URL: http://msdn.microsoft.com/library

C# Language Specification; URL: http://download.microsoft.com/download/0/B/D/0BDA894F-


2CCD-4C2C-B5A7-4EB1171962E5/CSharp%20Language%20Specixfication.doc

C# 4.0 The Complete Reference; Herbert Schildt; McGraw-Hill Osborne Media; 2010

You might also like