SlideShare uma empresa Scribd logo
1 de 31
Baixar para ler offline
Class and Method
           Programming in C#




              tnngo2@gmail.com
Class and Objects
Object-oriented programming

      Programming languages designed based on data and ways to
      manipulate data.

      Procedural Languages (Pascal, C) focus on ways


      Object-oriented Languages (C#, Java) focus on data
Features

      Abstraction
      Encapsulation
      Inheritance
      Polymorphism


                      Focus only the required information from objects
Features

      Abstraction

      Encapsulation
      Inheritance
      Polymorphism



                      Hide details of what a class contains
Features

      Abstraction

      Encapsulation

      Inheritance
      Polymorphism


                      Create a new class based on the attributes
                      and methods of an existing class
Features

      Abstraction

      Encapsulation
      Inheritance

      Polymorphism

                      Behave differently in different situations
Class
Class – should & cannot

      Should
               be a noun
               first letter capitalized
               simple, descriptive, meaningful
      Cannot
               in mixed case
               C# keyword
               begin with a digit except @, _
Methods
Method – can & cannot

     Can
           begin with a letter, _ or @
     Cannot
           C# keyword
           contain space
           begin with digit
Invoking methods

      https://gist.github.com/2349623
Static methods

      called without creating any objects of the class
      refer only to static variables and other static methods of class.

      https://gist.github.com/2349658
Static methods

      Only one copy of static variable is shared by all the objects of the
      class.
Question?

     https://gist.github.com/2349708
Access Modifiers
Access Modifiers
Ref

      causes arguments to be passed in a method by reference


      https://gist.github.com/2344456
Out

      similar to ref but no
                          required the variables that are passed by
      reference to be initialized

      https://gist.github.com/2344483
Method overloading
Method overloading

      every method has a signature which comprises
              the number of params
              the data types of params
              the order of params
Should and avoid

      Methods to be overloaded should perform the same task

      The signatures of the overloaded must be unique

      Return type is not a part of the signature

      The ref and out parameters can be included as a part of the
      signature
This keyword

      refer to the current object of the class.

      cannot use this keyword with static variables and method

      https://gist.github.com/2344534
Question?

     https://gist.github.com/2349708
Constructors and Destructors
Constructors

      initialization

      no return type

      possible to have overloaded constructors

      https://gist.github.com/2344570
Default Constructors

      C# creates a default constructors for a class if no constructor is
      specified within the class. It automatically initializes all the numeric
      data type instance variables to zero.

      If you define a constructor in the class, the default constructor is no
      longer used.
Static Constructors

      initialize static variables of the class and to perform a particular
      action only once.

      is invoked before any static member of the class is accessed.

      does not take any parameters and does not use any access modifiers
      because it is invoked directly by the CLR instead of the object.

      Certainly, cannot access non-static data member.

      https://gist.github.com/2344643
Constructor Overloading


      https://gist.github.com/2344673
Destructors

      invoked automatically when the objects are not in use

      only one destructor in a class

      cannot be overloaded or inherited

      cannot be explicitly invoked


      cannot specify access modifiers and cannot take parameters

      https://gist.github.com/2344708
Garbage Collector

Mais conteúdo relacionado

Mais procurados

C#, OOP introduction and examples
C#, OOP introduction and examplesC#, OOP introduction and examples
C#, OOP introduction and examplesagni_agbc
 
Object Oriented Programming - Basic Concepts
Object Oriented Programming - Basic ConceptsObject Oriented Programming - Basic Concepts
Object Oriented Programming - Basic ConceptsArunkumar Kupppuswamy
 
Object Oriented Principles
Object Oriented PrinciplesObject Oriented Principles
Object Oriented PrinciplesSujit Majety
 
4- Inheritance, Aggregation, Encapsulation and Overloading
4- Inheritance, Aggregation, Encapsulation and Overloading4- Inheritance, Aggregation, Encapsulation and Overloading
4- Inheritance, Aggregation, Encapsulation and OverloadingGhadeer AlHasan
 
Polymorphism presentation in java
Polymorphism presentation in javaPolymorphism presentation in java
Polymorphism presentation in javaAhsan Raja
 
Abap Inicio
Abap InicioAbap Inicio
Abap Iniciounifor
 
OOP in C#
OOP in C#OOP in C#
OOP in C#DevMix
 
Evolution of c# - by K.Jegan
Evolution of c# - by K.JeganEvolution of c# - by K.Jegan
Evolution of c# - by K.Jegantalenttransform
 
Abstract Class Presentation
Abstract Class PresentationAbstract Class Presentation
Abstract Class Presentationtigerwarn
 
OCP Java (OCPJP) 8 Exam Quick Reference Card
OCP Java (OCPJP) 8 Exam Quick Reference CardOCP Java (OCPJP) 8 Exam Quick Reference Card
OCP Java (OCPJP) 8 Exam Quick Reference CardHari kiran G
 
8abstact class in c#
8abstact class in c#8abstact class in c#
8abstact class in c#Sireesh K
 
OCA Java SE 8 Exam Chapter 2 Operators & Statements
OCA Java SE 8 Exam Chapter 2 Operators & StatementsOCA Java SE 8 Exam Chapter 2 Operators & Statements
OCA Java SE 8 Exam Chapter 2 Operators & Statementsİbrahim Kürce
 

Mais procurados (20)

C#
C#C#
C#
 
C#, OOP introduction and examples
C#, OOP introduction and examplesC#, OOP introduction and examples
C#, OOP introduction and examples
 
Object Oriented Programming - Basic Concepts
Object Oriented Programming - Basic ConceptsObject Oriented Programming - Basic Concepts
Object Oriented Programming - Basic Concepts
 
Object Oriented Principles
Object Oriented PrinciplesObject Oriented Principles
Object Oriented Principles
 
4- Inheritance, Aggregation, Encapsulation and Overloading
4- Inheritance, Aggregation, Encapsulation and Overloading4- Inheritance, Aggregation, Encapsulation and Overloading
4- Inheritance, Aggregation, Encapsulation and Overloading
 
Total oop in c# dot net
Total oop in c# dot netTotal oop in c# dot net
Total oop in c# dot net
 
Polymorphism presentation in java
Polymorphism presentation in javaPolymorphism presentation in java
Polymorphism presentation in java
 
Abap Inicio
Abap InicioAbap Inicio
Abap Inicio
 
Lecture 18
Lecture 18Lecture 18
Lecture 18
 
C# interview quesions
C# interview quesionsC# interview quesions
C# interview quesions
 
OOP in C#
OOP in C#OOP in C#
OOP in C#
 
C# interview questions
C# interview questionsC# interview questions
C# interview questions
 
Evolution of c# - by K.Jegan
Evolution of c# - by K.JeganEvolution of c# - by K.Jegan
Evolution of c# - by K.Jegan
 
Abstract Class Presentation
Abstract Class PresentationAbstract Class Presentation
Abstract Class Presentation
 
OCP Java (OCPJP) 8 Exam Quick Reference Card
OCP Java (OCPJP) 8 Exam Quick Reference CardOCP Java (OCPJP) 8 Exam Quick Reference Card
OCP Java (OCPJP) 8 Exam Quick Reference Card
 
C# interview
C# interviewC# interview
C# interview
 
Deciphering the Ruby Object Model
Deciphering the Ruby Object ModelDeciphering the Ruby Object Model
Deciphering the Ruby Object Model
 
8abstact class in c#
8abstact class in c#8abstact class in c#
8abstact class in c#
 
Classes objects in java
Classes objects in javaClasses objects in java
Classes objects in java
 
OCA Java SE 8 Exam Chapter 2 Operators & Statements
OCA Java SE 8 Exam Chapter 2 Operators & StatementsOCA Java SE 8 Exam Chapter 2 Operators & Statements
OCA Java SE 8 Exam Chapter 2 Operators & Statements
 

Destaque

Delação de Sérgio Machado na íntegra
Delação de Sérgio Machado na íntegraDelação de Sérgio Machado na íntegra
Delação de Sérgio Machado na íntegraMiguel Rosario
 
Overview of the Virginia Education Wizard
Overview of the Virginia Education WizardOverview of the Virginia Education Wizard
Overview of the Virginia Education Wizardchjensen
 
Carta descriptiva wiki
Carta descriptiva wikiCarta descriptiva wiki
Carta descriptiva wikiairamm87
 
Mass, Volume and Density Labs --Day 1
Mass, Volume and Density Labs --Day 1Mass, Volume and Density Labs --Day 1
Mass, Volume and Density Labs --Day 1jmori1
 
Managing Community Open Source Brands
Managing Community Open Source BrandsManaging Community Open Source Brands
Managing Community Open Source BrandsShane Curcuru
 
PHP Sessions and Non-Sessions
PHP Sessions and Non-SessionsPHP Sessions and Non-Sessions
PHP Sessions and Non-SessionsSven Rautenberg
 
Growing your school in troubled times, sbacs webinar
Growing your school in troubled times, sbacs webinarGrowing your school in troubled times, sbacs webinar
Growing your school in troubled times, sbacs webinarRick Newberry
 
Asia pacopenstack swiftstack-joe-arnold-2012-08-11
Asia pacopenstack swiftstack-joe-arnold-2012-08-11Asia pacopenstack swiftstack-joe-arnold-2012-08-11
Asia pacopenstack swiftstack-joe-arnold-2012-08-11OpenCity Community
 
KVH Carrier Solutions
KVH Carrier SolutionsKVH Carrier Solutions
KVH Carrier SolutionsKVH Co. Ltd.
 
Lesson 3
Lesson 3Lesson 3
Lesson 3hstryk
 
Yellow Umbrella Services Pvt. Ltd
Yellow Umbrella Services Pvt. LtdYellow Umbrella Services Pvt. Ltd
Yellow Umbrella Services Pvt. LtdYellow Umbrella
 
Intravert Server side processing for Cassandra
Intravert Server side processing for CassandraIntravert Server side processing for Cassandra
Intravert Server side processing for CassandraEdward Capriolo
 
Final project for eme 2040
Final project for eme 2040Final project for eme 2040
Final project for eme 2040ellapeters92
 
Manifesto do Congresso Internacional realizado na Unesp Bauru
Manifesto do Congresso Internacional realizado na Unesp BauruManifesto do Congresso Internacional realizado na Unesp Bauru
Manifesto do Congresso Internacional realizado na Unesp BauruMiguel Rosario
 

Destaque (20)

Delação de Sérgio Machado na íntegra
Delação de Sérgio Machado na íntegraDelação de Sérgio Machado na íntegra
Delação de Sérgio Machado na íntegra
 
Overview of the Virginia Education Wizard
Overview of the Virginia Education WizardOverview of the Virginia Education Wizard
Overview of the Virginia Education Wizard
 
Carta descriptiva wiki
Carta descriptiva wikiCarta descriptiva wiki
Carta descriptiva wiki
 
Mass, Volume and Density Labs --Day 1
Mass, Volume and Density Labs --Day 1Mass, Volume and Density Labs --Day 1
Mass, Volume and Density Labs --Day 1
 
Managing Community Open Source Brands
Managing Community Open Source BrandsManaging Community Open Source Brands
Managing Community Open Source Brands
 
PHP Sessions and Non-Sessions
PHP Sessions and Non-SessionsPHP Sessions and Non-Sessions
PHP Sessions and Non-Sessions
 
Growing your school in troubled times, sbacs webinar
Growing your school in troubled times, sbacs webinarGrowing your school in troubled times, sbacs webinar
Growing your school in troubled times, sbacs webinar
 
Asia pacopenstack swiftstack-joe-arnold-2012-08-11
Asia pacopenstack swiftstack-joe-arnold-2012-08-11Asia pacopenstack swiftstack-joe-arnold-2012-08-11
Asia pacopenstack swiftstack-joe-arnold-2012-08-11
 
Track
TrackTrack
Track
 
Ig3 2012_assignment
 Ig3 2012_assignment Ig3 2012_assignment
Ig3 2012_assignment
 
KVH Carrier Solutions
KVH Carrier SolutionsKVH Carrier Solutions
KVH Carrier Solutions
 
Lesson 3
Lesson 3Lesson 3
Lesson 3
 
Yellow Umbrella Services Pvt. Ltd
Yellow Umbrella Services Pvt. LtdYellow Umbrella Services Pvt. Ltd
Yellow Umbrella Services Pvt. Ltd
 
Intravert Server side processing for Cassandra
Intravert Server side processing for CassandraIntravert Server side processing for Cassandra
Intravert Server side processing for Cassandra
 
Final project for eme 2040
Final project for eme 2040Final project for eme 2040
Final project for eme 2040
 
Manifesto do Congresso Internacional realizado na Unesp Bauru
Manifesto do Congresso Internacional realizado na Unesp BauruManifesto do Congresso Internacional realizado na Unesp Bauru
Manifesto do Congresso Internacional realizado na Unesp Bauru
 
Brics
BricsBrics
Brics
 
Sambo
Sambo Sambo
Sambo
 
Startgids Medewerker
Startgids MedewerkerStartgids Medewerker
Startgids Medewerker
 
Data Collection
Data CollectionData Collection
Data Collection
 

Semelhante a 6 class and methods

Semelhante a 6 class and methods (20)

Object-oriented programming 3.pptx
Object-oriented programming 3.pptxObject-oriented programming 3.pptx
Object-oriented programming 3.pptx
 
Python_Unit_3.pdf
Python_Unit_3.pdfPython_Unit_3.pdf
Python_Unit_3.pdf
 
LectureNotes-02-DSA
LectureNotes-02-DSALectureNotes-02-DSA
LectureNotes-02-DSA
 
Object Oriented Programming C#
Object Oriented Programming C#Object Oriented Programming C#
Object Oriented Programming C#
 
PPT Lecture-1.4.pptx
PPT Lecture-1.4.pptxPPT Lecture-1.4.pptx
PPT Lecture-1.4.pptx
 
Java
JavaJava
Java
 
java tutorial 4
 java tutorial 4 java tutorial 4
java tutorial 4
 
Oo abap-sap-1206973306636228-5
Oo abap-sap-1206973306636228-5Oo abap-sap-1206973306636228-5
Oo abap-sap-1206973306636228-5
 
Presentation 3rd
Presentation 3rdPresentation 3rd
Presentation 3rd
 
Java/J2EE interview Qestions
Java/J2EE interview QestionsJava/J2EE interview Qestions
Java/J2EE interview Qestions
 
7 inheritance and polymorphism
7   inheritance and polymorphism7   inheritance and polymorphism
7 inheritance and polymorphism
 
Java session2
Java session2Java session2
Java session2
 
C# - Igor Ralić
C# - Igor RalićC# - Igor Ralić
C# - Igor Ralić
 
Java scjp-part1
Java scjp-part1Java scjp-part1
Java scjp-part1
 
Classes2
Classes2Classes2
Classes2
 
C# classes objects
C#  classes objectsC#  classes objects
C# classes objects
 
Application package
Application packageApplication package
Application package
 
Code Refactoring
Code RefactoringCode Refactoring
Code Refactoring
 
116824015 java-j2 ee
116824015 java-j2 ee116824015 java-j2 ee
116824015 java-j2 ee
 
Java OOPs
Java OOPs Java OOPs
Java OOPs
 

Mais de Tuan Ngo

Introduction of cg program for portal 20120424 en
Introduction of cg program for portal 20120424 enIntroduction of cg program for portal 20120424 en
Introduction of cg program for portal 20120424 enTuan Ngo
 
Net framework
Net frameworkNet framework
Net frameworkTuan Ngo
 
15 anonymous methods, partial types and nullable types
15   anonymous methods, partial types and nullable types15   anonymous methods, partial types and nullable types
15 anonymous methods, partial types and nullable typesTuan Ngo
 
14 generics and iterators
14   generics and iterators14   generics and iterators
14 generics and iteratorsTuan Ngo
 
13 collections
13   collections13   collections
13 collectionsTuan Ngo
 
11 exception handling
11   exception handling11   exception handling
11 exception handlingTuan Ngo
 
12 events and delegates
12   events and delegates12   events and delegates
12 events and delegatesTuan Ngo
 
9 properties & indexers
9   properties & indexers9   properties & indexers
9 properties & indexersTuan Ngo
 
10 namespace
10  namespace10  namespace
10 namespaceTuan Ngo
 
8 abstract classes and interfaces
8   abstract classes and interfaces 8   abstract classes and interfaces
8 abstract classes and interfaces Tuan Ngo
 
3 statements and operators
3   statements and operators3   statements and operators
3 statements and operatorsTuan Ngo
 
4 c# programming constructs
4   c# programming constructs4   c# programming constructs
4 c# programming constructsTuan Ngo
 
1 get started with c#
1   get started with c#1   get started with c#
1 get started with c#Tuan Ngo
 
2 variables and data types
2   variables and data types2   variables and data types
2 variables and data typesTuan Ngo
 

Mais de Tuan Ngo (20)

Introduction of cg program for portal 20120424 en
Introduction of cg program for portal 20120424 enIntroduction of cg program for portal 20120424 en
Introduction of cg program for portal 20120424 en
 
Net framework
Net frameworkNet framework
Net framework
 
15 anonymous methods, partial types and nullable types
15   anonymous methods, partial types and nullable types15   anonymous methods, partial types and nullable types
15 anonymous methods, partial types and nullable types
 
14 generics and iterators
14   generics and iterators14   generics and iterators
14 generics and iterators
 
13 collections
13   collections13   collections
13 collections
 
11 exception handling
11   exception handling11   exception handling
11 exception handling
 
12 events and delegates
12   events and delegates12   events and delegates
12 events and delegates
 
9 properties & indexers
9   properties & indexers9   properties & indexers
9 properties & indexers
 
10 namespace
10  namespace10  namespace
10 namespace
 
8 abstract classes and interfaces
8   abstract classes and interfaces 8   abstract classes and interfaces
8 abstract classes and interfaces
 
5 arrays
5   arrays5   arrays
5 arrays
 
3 statements and operators
3   statements and operators3   statements and operators
3 statements and operators
 
4 c# programming constructs
4   c# programming constructs4   c# programming constructs
4 c# programming constructs
 
1 get started with c#
1   get started with c#1   get started with c#
1 get started with c#
 
2 variables and data types
2   variables and data types2   variables and data types
2 variables and data types
 
Jdbc 7
Jdbc 7Jdbc 7
Jdbc 7
 
Jdbc 6
Jdbc 6Jdbc 6
Jdbc 6
 
Jdbc 3
Jdbc 3Jdbc 3
Jdbc 3
 
Jdbc 2
Jdbc 2Jdbc 2
Jdbc 2
 
Php
PhpPhp
Php
 

Último

Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...gurkirankumar98700
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEarley Information Science
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking MenDelhi Call girls
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024The Digital Insurer
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsMaria Levchenko
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024The Digital Insurer
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)Gabriella Davis
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘RTylerCroy
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Enterprise Knowledge
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking MenDelhi Call girls
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationRadu Cotescu
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024Rafal Los
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024The Digital Insurer
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Drew Madelung
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Allon Mureinik
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Igalia
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024Results
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdfhans926745
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfEnterprise Knowledge
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxKatpro Technologies
 

Último (20)

Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
 

6 class and methods

  • 1. Class and Method Programming in C# tnngo2@gmail.com
  • 3. Object-oriented programming Programming languages designed based on data and ways to manipulate data. Procedural Languages (Pascal, C) focus on ways Object-oriented Languages (C#, Java) focus on data
  • 4. Features Abstraction Encapsulation Inheritance Polymorphism Focus only the required information from objects
  • 5. Features Abstraction Encapsulation Inheritance Polymorphism Hide details of what a class contains
  • 6. Features Abstraction Encapsulation Inheritance Polymorphism Create a new class based on the attributes and methods of an existing class
  • 7. Features Abstraction Encapsulation Inheritance Polymorphism Behave differently in different situations
  • 9. Class – should & cannot Should be a noun first letter capitalized simple, descriptive, meaningful Cannot in mixed case C# keyword begin with a digit except @, _
  • 11. Method – can & cannot Can begin with a letter, _ or @ Cannot C# keyword contain space begin with digit
  • 12. Invoking methods https://gist.github.com/2349623
  • 13. Static methods called without creating any objects of the class refer only to static variables and other static methods of class. https://gist.github.com/2349658
  • 14. Static methods Only one copy of static variable is shared by all the objects of the class.
  • 15. Question? https://gist.github.com/2349708
  • 18. Ref causes arguments to be passed in a method by reference https://gist.github.com/2344456
  • 19. Out similar to ref but no required the variables that are passed by reference to be initialized https://gist.github.com/2344483
  • 21. Method overloading every method has a signature which comprises the number of params the data types of params the order of params
  • 22. Should and avoid Methods to be overloaded should perform the same task The signatures of the overloaded must be unique Return type is not a part of the signature The ref and out parameters can be included as a part of the signature
  • 23. This keyword refer to the current object of the class. cannot use this keyword with static variables and method https://gist.github.com/2344534
  • 24. Question? https://gist.github.com/2349708
  • 26. Constructors initialization no return type possible to have overloaded constructors https://gist.github.com/2344570
  • 27. Default Constructors C# creates a default constructors for a class if no constructor is specified within the class. It automatically initializes all the numeric data type instance variables to zero. If you define a constructor in the class, the default constructor is no longer used.
  • 28. Static Constructors initialize static variables of the class and to perform a particular action only once. is invoked before any static member of the class is accessed. does not take any parameters and does not use any access modifiers because it is invoked directly by the CLR instead of the object. Certainly, cannot access non-static data member. https://gist.github.com/2344643
  • 29. Constructor Overloading https://gist.github.com/2344673
  • 30. Destructors invoked automatically when the objects are not in use only one destructor in a class cannot be overloaded or inherited cannot be explicitly invoked cannot specify access modifiers and cannot take parameters https://gist.github.com/2344708