Features of Object Oriented Programming:  A class is a collection of things which posses common similarities.  In C#.NET a class is a user defined.

Slides:



Advertisements
Similar presentations
1 Generic Collections Chapter Objectives You will be able to Use generic collection classes available in the.NET framework.
Advertisements

INHERITANCE BASICS Reusability is achieved by INHERITANCE
Unit 08 & 091 Nested Classes Introduction Inner Classes Local Classes Anonymous Classes Exercises.
תכנות ב C#. דוגמא לפלט using System; using System.Collections.Generic; using System.Text; namespace ConsoleApplication1 { class Program { static void.
OOP in Java Nelson Padua-Perez Chau-Wen Tseng Department of Computer Science University of Maryland, College Park.
C#.NET C# language. C# A modern, general-purpose object-oriented language Part of the.NET family of languages ECMA standard Based on C and C++
Lecture 9 Concepts of Programming Languages
Java CourseWinter 2009/10. Introduction Object oriented, imperative programming language. Developed: Inspired by C++ programming language.
Differences between C# and C++ Dr. Catherine Stringfellow Dr. Stewart Carpenter.
C# Tutorial From C++ to C#. Some useful links Msdn C# us/library/kx37x362.aspxhttp://msdn.microsoft.com/en- us/library/kx37x362.aspx.
Lecture 5 What is object-oriented programming OOP techniques How Windows Forms applications rely on OOP.
Introduction to Classes SWE 344 Internet Protocols & Client Server Programming.
Object Oriented Programming Concepts OOP – reasoning about a program as a set of objects rather than as a set of actions Object – a programming entity.
Encapsulation, Inheritance & Polymorphism. OOP Properties Encapsulation ­The process of creating programs so that information within a class is not accessible.
Session 08 Module 14: Generics and Iterator Module 15: Anonymous & partial class & Nullable type.
ILM Proprietary and Confidential -
CIS 3301 C# Lesson 7 Introduction to Classes. CIS 3302 Objectives Implement Constructors. Know the difference between instance and static members. Understand.
Programming using C# for Teachers Introduction to Objects Reference Types Functions of Classes Attributes and Types to a class LECTURE 2.
Session 04 Module 8: Abstract classes and Interface Module 9: Properties and Indexers.
1 Interfaces and Abstract Classes Chapter Objectives You will be able to: Write Interface definitions and class definitions that implement them.
1 Abstract Classes and Interfaces. 2 The abstract Modifier  The abstract class –Cannot be instantiated –Should be extended and implemented in subclasses.
MIT AITI 2004 – Lecture 13 Abstract Classes and Interfaces.
Recitation 8 User Defined Classes Part 2. Class vs. Instance methods Compare the Math and String class methods that we have used: – Math.pow(2,3); – str.charAt(4);
Introduction to Object-Oriented Programming Lesson 2.
Topics Inheritance introduction
Java Programming Final Keyword In Java. final keyword The final keyword in java is used to restrict the user. The final keyword can be used in many context.
Access Specifier. Anything declared public can be accessed from anywhere. Anything declared private cannot be seen outside of its class. When a member.
Introduction to C# By: Abir Ghattas Michel Barakat.
 A class is a collection of things which posses common similarities.  In C#.NET a class is a user defined Data type and is Known as Reference.
INPUT/OUTPUT STATEMENT ADDITION SLIDES. Console.ReadLine() – Use to get the input (String) from user Convert string to other data type – int.Parse() 
Presented by Ted Higgins, SQL Server DBA An Introduction to Object – Oriented Programming.
Class Inheritance SWE 344 Internet Protocols & Client Server Programming.
CSI 3125, Preliminaries, page 1 Inheritance. CSI 3125, Preliminaries, page 2 Inheritance Using inheritance, can create a general class that defines traits.
1 C# - Inheritance and Polymorphism. 2 1.Inheritance 2.Implementing Inheritance in C# 3.Constructor calls in Inheritance 4.Protected Access Modifier 5.The.
Java Inheritance in Java. Inheritance Inheritance is a mechanism in which one object acquires all the properties and behaviors of parent object. The idea.
COMPUTER SCIENCE & TECHNOLOGY DEGREE PROGRAMME FACULTY OF SCIENCE & TECHNOLOGY UNIVERSITY OF UVA WELLASSA ‏ Properties of Object Oriented Programming.
METADATA IN.NET Presented By Sukumar Manduva. INTRODUCTION  What is Metadata ? Metadata is a binary information which contains the complete description.
Programming in Java Transitioning from Alice. Becomes not myFirstMethod but …. public static void main (String[] arg) { // code for testing classes goes.
Inheritance. Inheritance is a mechanism in which one object acquires all the properties and behaviors of parent object Inheritance represents the IS-A.
Building Web Applications with Microsoft ASP
Modern Programming Tools And Techniques-I
C# for C++ Programmers 1.
Creating and Using Objects, Exceptions, Strings
NESTED CLASSES REFLECTION PROXIES.
Chapter - 4 OOP with C# S. Nandagopalan.
Lecture 12 Inheritance.
Static data members Constructors and Destructors
התוכנית: using System; using System.Collections.Generic;
using System; namespace Demo01 { class Program
2.7 Inheritance Types of inheritance
C# Arrays.
Inheritance and Polymorphism
Interface.
CS360 Windows Programming
OOP’S Concepts in C#.Net
Lecture 9 Concepts of Programming Languages
Functions Used to write code only once Can use parameters.
Interface.
Introduction interface in Java is a blueprint of a class. It has static constants and abstract methods only. An interface is a way to describe what classes.
Classes & Objects: Examples
Interfaces.
عرض اجمالي المهام الشرطية في سي شارب (الأمر if)
Sampath Kumar S Assistant Professor, SECE
METHOD OVERRIDING in JAVA
Inheritance Inheritance is a fundamental Object Oriented concept
Inheritance Cse 3rd year.
class PrintOnetoTen { public static void main(String args[]) {
Chapter 13 Exception Handling: A Deeper Look
Lecture 9 Concepts of Programming Languages
INTERFACES Explained By: Sarbjit Kaur. Lecturer, Department of Computer Application, PGG.C.G., Sector: 42, Chandigarh.
Presentation transcript:

Features of Object Oriented Programming:

 A class is a collection of things which posses common similarities.  In C#.NET a class is a user defined Data type and is Known as Reference Type.  A class can contain following members in C#.NET  A class is a collection of things which posses common similarities.  In C#.NET a class is a user defined Data type and is Known as Reference Type.  A class can contain following members in C#.NET

 It’s used to store the data related to the class.  Except Data Fields no other member of a class can store the data.  To declare any Data Field, we use the following

1 2 2

using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace ClsEmployee1 { class Program { int eid, eage; string ename, eaddress; public Program() { this.eid = 101; this.ename = "sai"; this.eaddress = "mcl"; this.eage = 24; } public void DisplayEmpData() { Console.WriteLine("eida is "+eid); Console.WriteLine("ename is"+ename); Console.WriteLine("eaddress is " +eaddress); Console.WriteLine("eage is" + eage); } class ClsUDConst { static void Main(string[] args) { Program obj1 = new Program(); Program obj2 = new Program(); obj1.DisplayEmpData(); obj2.DisplayEmpData(); Console.Read(); }

[ ] class : Class Class1 { Members } Class Class2 : Class1 { Consume the parent members here }

Example program

1 Read Only Property 2 Write Only Property 3 Read Write property  This property is used to read the data from the Data field  It is used to write the data into Data field of a class.  It is used to read the data from the Data field and to write the data in to the Data Field

Access Modifier Data Type property Name { set { Data Field Name=Value; } get { return data Field Name; } Namespace CAProperties { Class clsEmpolyee { int EmpId,EAge; Public int PEmpId { set { EmpId=value; } get { return EmpId; }

Public int PEAge { set { EAge=Value; } get { return EAge; } Class ClsProperty1 { Static void Main(string[] args) { clsEmployee obj1=new clsEmployee(); Console.write(“Enter Employee details:”); Obj1.PEmpId=Concert.ToInt32(Console.ReadLine()); Obj1.PEAge=convert.ToInt32(console.ReadLine()); }

 In the.NET Framework, interfaces have a special naming convention. All interface name begin with a capital I. Interfaces can have properties as we difference from a class. 1.You cannot create an object of an interface 2.An interface does not contain any constructor. 3.All methods in an interface are abstract. 4.An interface can inherit multiple interfaces.

Public void Div (int x, int y) { Console.Writeline(x/y) } public void Test () { Console.Writeline (“Declared under multiple interfaces”); } Void Inter1.Test () { Console.Writeline (“Method of Interfaced 1”); } Void Inter2.Test () { Console.Writeline (“Method of Interfaced 2”); } Public void Div (int x, int y) { Console.Writeline(x/y) } public void Test () { Console.Writeline (“Declared under multiple interfaces”); } Void Inter1.Test () { Console.Writeline (“Method of Interfaced 1”); } Void Inter2.Test () { Console.Writeline (“Method of Interfaced 2”); } Static Void Main () { Inter class obj= new Inter class (); Obj. Add (100, 45); Obj. Sub (100, 45); Obj. Mul (100, 45); Obj.Div (100, 45); Obj. Test (); Inter1 i1 = obj; Inter i2 = obj; I1.Test (); i2.Test (); Console.ReadLine (); } Static Void Main () { Inter class obj= new Inter class (); Obj. Add (100, 45); Obj. Sub (100, 45); Obj. Mul (100, 45); Obj.Div (100, 45); Obj. Test (); Inter1 i1 = obj; Inter i2 = obj; I1.Test (); i2.Test (); Console.ReadLine (); }

Add a class del.cs and write the following the code Class Delclass { Public String SayHello(string name0 { Return “Hello” +name; } Public delegate string SayDel(String name); Static void Main() { Delclass obj=new Delclass(); SayDel Sd=new SayDel(obj.sayHellow); Console.WriteLine(Sd(“xxx”)); Console.WrireLine(Sd(“yyy”)); Console.WrireLine(Sd(“zzz”)); Console.ReadLine(); }