SlideShare a Scribd company logo
Learn C# Programming
Interfaces & Namespaces
Eng Teong Cheah
MVP Visual Studio & Development Technologies
Interfaces
Interfaces
An interface is defined as a syntactical contract that all the classes inheriting the
interface should follow. The interface defines the ‘what’ part of the syntactical contract
and the deriving classes define the ‘how’ party of the syntactical contract.
Interfaces defines properties, methods, and events, which are the members of the
interface. Interfaces contain only the declaration of the members. It is the responsibility f
the deriving class to define the members. It often helps in providing a standard structure
that the deriving classes would follow.
Abstract classes to some extent serve the same purpose, however, they are mostly used
when only few methods are to be declared by the base class and the deriving class
implements the functionalities.
Declaring Interfaces
Interfaces are declared using the interface keyword.
It is similar to class declaration.
Interface statements are public by default.
Demo – Interfaces
Namespaces
Namespaces
A namespace is designed for providing a way to keep one set of names separate from
another. The class names declared in one namespace does not conflict with the same
class names declared in another.
Defining a Namespace
A namespace definition begins with the keyword namespace followed by the
namespace name as follows –
namespace namespace_name {
// code declarations
}
To call the namespace-enabled version of either function or variable, prepend the
namespace name as follows-
namespace_name.item_name;
Demo – Defining a
Namespace
The using Keyword
The using keyword states that the program is using the names in the given
namespace.
For example, we are using the System namespace in our programs.
The class Console is defined there. We just write –
Console.WriteLine ("Hello there");
The using Keyword
We could have written the fully qualified name as -
Console.WriteLine ("Hello there");
You can also avoid prepending of namespaces with the using namespace
directive.
This directive tells the compiler that the subsequent code is making use of names
in the specified namespace.
Demo – The using
keyword
Nested Namespaces
You can define one namespace inside another namespace as follows –
namespace namespace_name1 {
// code declarations
namespace namespace_name2 {
// code declarations
}
}
Demo – Nested
Namespace
Related Content
TutorialsPoint
www.tutorialspoint.com
Thank you

More Related Content

PPTX
Polymorphism and interface in vb.net
KarthigaGunasekaran1
 
PPTX
Java presentation
Akteruzzaman .
 
PPT
Java interface
Arati Gadgil
 
PDF
What is Interface in Java | How to implement Multiple Inheritance Using Inter...
Edureka!
 
PPTX
Visual Basic –User Interface- V
Sharbani Bhattacharya
 
PPT
Chapter 9 Interface
OUM SAOKOSAL
 
PPT
Codings Standards
Philip Johnson
 
PPTX
15 interfaces
dhrubo kayal
 
Polymorphism and interface in vb.net
KarthigaGunasekaran1
 
Java presentation
Akteruzzaman .
 
Java interface
Arati Gadgil
 
What is Interface in Java | How to implement Multiple Inheritance Using Inter...
Edureka!
 
Visual Basic –User Interface- V
Sharbani Bhattacharya
 
Chapter 9 Interface
OUM SAOKOSAL
 
Codings Standards
Philip Johnson
 
15 interfaces
dhrubo kayal
 

What's hot (14)

PDF
Java OOP Programming language (Part 6) - Abstract Class & Interface
OUM SAOKOSAL
 
PDF
Xamarin: Inheritance and Polymorphism
Eng Teong Cheah
 
PDF
What are Generics in Java | Java Generics Tutorial | Edureka
Edureka!
 
DOCX
Java interface
HoneyChintal
 
PPTX
abstract class and interface.Net
BGSBU Rajouri
 
DOCX
Mit4021 c# and .net
smumbahelp
 
PPT
Interface in java By Dheeraj Kumar Singh
dheeraj_cse
 
PPT
Interfaces In Java
parag
 
PPTX
Interface in java ,multiple inheritance in java, interface implementation
HoneyChintal
 
PPTX
Lecture 1 uml with java implementation
the_wumberlog
 
PPTX
Java interfaces
jehan1987
 
DOCX
Bt0074
smumbahelp
 
PPTX
Class Diagram | OOP and Design Patterns by Oum Saokosal
OUM SAOKOSAL
 
PDF
8 abstract classes and interfaces
Tuan Ngo
 
Java OOP Programming language (Part 6) - Abstract Class & Interface
OUM SAOKOSAL
 
Xamarin: Inheritance and Polymorphism
Eng Teong Cheah
 
What are Generics in Java | Java Generics Tutorial | Edureka
Edureka!
 
Java interface
HoneyChintal
 
abstract class and interface.Net
BGSBU Rajouri
 
Mit4021 c# and .net
smumbahelp
 
Interface in java By Dheeraj Kumar Singh
dheeraj_cse
 
Interfaces In Java
parag
 
Interface in java ,multiple inheritance in java, interface implementation
HoneyChintal
 
Lecture 1 uml with java implementation
the_wumberlog
 
Java interfaces
jehan1987
 
Bt0074
smumbahelp
 
Class Diagram | OOP and Design Patterns by Oum Saokosal
OUM SAOKOSAL
 
8 abstract classes and interfaces
Tuan Ngo
 
Ad

Similar to Learn C# programming - Interfaces & Namespaces (20)

PDF
International Journal of Engineering Research and Development (IJERD)
IJERD Editor
 
PDF
International Journal of Engineering Research and Development (IJERD)
IJERD Editor
 
PPTX
1using in c#
Sireesh K
 
PPTX
Namespaces in C#
yogita kachve
 
DOCX
csharp.docx
LenchoMamudeBaro
 
PPTX
Back-2-Basics: .NET Coding Standards For The Real World
David McCarter
 
PPTX
Back-2-Basics: .NET Coding Standards For The Real World
David McCarter
 
PPTX
VP-303 lecture#9.pptx
Syed Ejaz
 
PPTX
C# XML documentation
Roman Okolovich
 
DOCX
NamingConvention
Jabed Hossain
 
PDF
Bt0074 oops with java2
Techglyphs
 
PPTX
Java syntax-and-grammars-oct8
MISSIASABTAL1
 
PPTX
Writing High Quality Code in C#
Svetlin Nakov
 
PPTX
Top 20 c# interview Question and answers
w3asp dotnet
 
PDF
C#.net interview questions for dynamics 365 ce crm developers
Sanjaya Prakash Pradhan
 
DOCX
Java notes
Upasana Talukdar
 
PDF
THE CLR AND THE .NET FRAMEWORK, C#
MANOJ BURI
 
PDF
C# chap 3
Shehrevar Davierwala
 
PDF
Why Drupal is Rockstar?
Gerald Villorente
 
International Journal of Engineering Research and Development (IJERD)
IJERD Editor
 
International Journal of Engineering Research and Development (IJERD)
IJERD Editor
 
1using in c#
Sireesh K
 
Namespaces in C#
yogita kachve
 
csharp.docx
LenchoMamudeBaro
 
Back-2-Basics: .NET Coding Standards For The Real World
David McCarter
 
Back-2-Basics: .NET Coding Standards For The Real World
David McCarter
 
VP-303 lecture#9.pptx
Syed Ejaz
 
C# XML documentation
Roman Okolovich
 
NamingConvention
Jabed Hossain
 
Bt0074 oops with java2
Techglyphs
 
Java syntax-and-grammars-oct8
MISSIASABTAL1
 
Writing High Quality Code in C#
Svetlin Nakov
 
Top 20 c# interview Question and answers
w3asp dotnet
 
C#.net interview questions for dynamics 365 ce crm developers
Sanjaya Prakash Pradhan
 
Java notes
Upasana Talukdar
 
THE CLR AND THE .NET FRAMEWORK, C#
MANOJ BURI
 
Why Drupal is Rockstar?
Gerald Villorente
 
Ad

More from Eng Teong Cheah (20)

PDF
Modern Cross-Platform Apps with .NET MAUI
Eng Teong Cheah
 
PDF
Efficiently Removing Duplicates from a Sorted Array
Eng Teong Cheah
 
PDF
Monitoring Models
Eng Teong Cheah
 
PDF
Responsible Machine Learning
Eng Teong Cheah
 
PDF
Training Optimal Models
Eng Teong Cheah
 
PDF
Deploying Models
Eng Teong Cheah
 
PDF
Machine Learning Workflows
Eng Teong Cheah
 
PDF
Working with Compute
Eng Teong Cheah
 
PDF
Working with Data
Eng Teong Cheah
 
PDF
Experiments & TrainingModels
Eng Teong Cheah
 
PDF
Automated Machine Learning
Eng Teong Cheah
 
PDF
Getting Started with Azure Machine Learning
Eng Teong Cheah
 
PDF
Hacking Containers - Container Storage
Eng Teong Cheah
 
PDF
Hacking Containers - Looking at Cgroups
Eng Teong Cheah
 
PDF
Hacking Containers - Linux Containers
Eng Teong Cheah
 
PDF
Data Security - Storage Security
Eng Teong Cheah
 
PDF
Application Security- App security
Eng Teong Cheah
 
PDF
Application Security - Key Vault
Eng Teong Cheah
 
PDF
Compute Security - Container Security
Eng Teong Cheah
 
PDF
Compute Security - Host Security
Eng Teong Cheah
 
Modern Cross-Platform Apps with .NET MAUI
Eng Teong Cheah
 
Efficiently Removing Duplicates from a Sorted Array
Eng Teong Cheah
 
Monitoring Models
Eng Teong Cheah
 
Responsible Machine Learning
Eng Teong Cheah
 
Training Optimal Models
Eng Teong Cheah
 
Deploying Models
Eng Teong Cheah
 
Machine Learning Workflows
Eng Teong Cheah
 
Working with Compute
Eng Teong Cheah
 
Working with Data
Eng Teong Cheah
 
Experiments & TrainingModels
Eng Teong Cheah
 
Automated Machine Learning
Eng Teong Cheah
 
Getting Started with Azure Machine Learning
Eng Teong Cheah
 
Hacking Containers - Container Storage
Eng Teong Cheah
 
Hacking Containers - Looking at Cgroups
Eng Teong Cheah
 
Hacking Containers - Linux Containers
Eng Teong Cheah
 
Data Security - Storage Security
Eng Teong Cheah
 
Application Security- App security
Eng Teong Cheah
 
Application Security - Key Vault
Eng Teong Cheah
 
Compute Security - Container Security
Eng Teong Cheah
 
Compute Security - Host Security
Eng Teong Cheah
 

Recently uploaded (20)

PDF
Presentation about Hardware and Software in Computer
snehamodhawadiya
 
PDF
BLW VOCATIONAL TRAINING SUMMER INTERNSHIP REPORT
codernjn73
 
PDF
Event Presentation Google Cloud Next Extended 2025
minhtrietgect
 
PPTX
Coupa-Overview _Assumptions presentation
annapureddyn
 
PDF
Unlocking the Future- AI Agents Meet Oracle Database 23ai - AIOUG Yatra 2025.pdf
Sandesh Rao
 
PDF
Security features in Dell, HP, and Lenovo PC systems: A research-based compar...
Principled Technologies
 
PDF
Structs to JSON: How Go Powers REST APIs
Emily Achieng
 
PDF
CIFDAQ's Market Wrap : Bears Back in Control?
CIFDAQ
 
PDF
Brief History of Internet - Early Days of Internet
sutharharshit158
 
PPTX
New ThousandEyes Product Innovations: Cisco Live June 2025
ThousandEyes
 
PDF
MASTERDECK GRAPHSUMMIT SYDNEY (Public).pdf
Neo4j
 
PDF
Cloud-Migration-Best-Practices-A-Practical-Guide-to-AWS-Azure-and-Google-Clou...
Artjoker Software Development Company
 
PPTX
cloud computing vai.pptx for the project
vaibhavdobariyal79
 
PDF
Automating ArcGIS Content Discovery with FME: A Real World Use Case
Safe Software
 
PDF
Trying to figure out MCP by actually building an app from scratch with open s...
Julien SIMON
 
PDF
NewMind AI Weekly Chronicles - July'25 - Week IV
NewMind AI
 
PDF
The Evolution of KM Roles (Presented at Knowledge Summit Dublin 2025)
Enterprise Knowledge
 
PDF
Architecture of the Future (09152021)
EdwardMeyman
 
PPTX
ChatGPT's Deck on The Enduring Legacy of Fax Machines
Greg Swan
 
PPT
Coupa-Kickoff-Meeting-Template presentai
annapureddyn
 
Presentation about Hardware and Software in Computer
snehamodhawadiya
 
BLW VOCATIONAL TRAINING SUMMER INTERNSHIP REPORT
codernjn73
 
Event Presentation Google Cloud Next Extended 2025
minhtrietgect
 
Coupa-Overview _Assumptions presentation
annapureddyn
 
Unlocking the Future- AI Agents Meet Oracle Database 23ai - AIOUG Yatra 2025.pdf
Sandesh Rao
 
Security features in Dell, HP, and Lenovo PC systems: A research-based compar...
Principled Technologies
 
Structs to JSON: How Go Powers REST APIs
Emily Achieng
 
CIFDAQ's Market Wrap : Bears Back in Control?
CIFDAQ
 
Brief History of Internet - Early Days of Internet
sutharharshit158
 
New ThousandEyes Product Innovations: Cisco Live June 2025
ThousandEyes
 
MASTERDECK GRAPHSUMMIT SYDNEY (Public).pdf
Neo4j
 
Cloud-Migration-Best-Practices-A-Practical-Guide-to-AWS-Azure-and-Google-Clou...
Artjoker Software Development Company
 
cloud computing vai.pptx for the project
vaibhavdobariyal79
 
Automating ArcGIS Content Discovery with FME: A Real World Use Case
Safe Software
 
Trying to figure out MCP by actually building an app from scratch with open s...
Julien SIMON
 
NewMind AI Weekly Chronicles - July'25 - Week IV
NewMind AI
 
The Evolution of KM Roles (Presented at Knowledge Summit Dublin 2025)
Enterprise Knowledge
 
Architecture of the Future (09152021)
EdwardMeyman
 
ChatGPT's Deck on The Enduring Legacy of Fax Machines
Greg Swan
 
Coupa-Kickoff-Meeting-Template presentai
annapureddyn
 

Learn C# programming - Interfaces & Namespaces

  • 1. Learn C# Programming Interfaces & Namespaces Eng Teong Cheah MVP Visual Studio & Development Technologies
  • 3. Interfaces An interface is defined as a syntactical contract that all the classes inheriting the interface should follow. The interface defines the ‘what’ part of the syntactical contract and the deriving classes define the ‘how’ party of the syntactical contract. Interfaces defines properties, methods, and events, which are the members of the interface. Interfaces contain only the declaration of the members. It is the responsibility f the deriving class to define the members. It often helps in providing a standard structure that the deriving classes would follow. Abstract classes to some extent serve the same purpose, however, they are mostly used when only few methods are to be declared by the base class and the deriving class implements the functionalities.
  • 4. Declaring Interfaces Interfaces are declared using the interface keyword. It is similar to class declaration. Interface statements are public by default.
  • 7. Namespaces A namespace is designed for providing a way to keep one set of names separate from another. The class names declared in one namespace does not conflict with the same class names declared in another.
  • 8. Defining a Namespace A namespace definition begins with the keyword namespace followed by the namespace name as follows – namespace namespace_name { // code declarations } To call the namespace-enabled version of either function or variable, prepend the namespace name as follows- namespace_name.item_name;
  • 9. Demo – Defining a Namespace
  • 10. The using Keyword The using keyword states that the program is using the names in the given namespace. For example, we are using the System namespace in our programs. The class Console is defined there. We just write – Console.WriteLine ("Hello there");
  • 11. The using Keyword We could have written the fully qualified name as - Console.WriteLine ("Hello there"); You can also avoid prepending of namespaces with the using namespace directive. This directive tells the compiler that the subsequent code is making use of names in the specified namespace.
  • 12. Demo – The using keyword
  • 13. Nested Namespaces You can define one namespace inside another namespace as follows – namespace namespace_name1 { // code declarations namespace namespace_name2 { // code declarations } }