Module 5: Common Type System

Slides:



Advertisements
Similar presentations
Introduction to Web Application
Advertisements

OBJECT-ORIENTED PROGRAMMING. What is an “object”? Abstract entity that contains data and actions Attributes (characteristics) and methods (functions)
Microsoft.NET Fundamentals. Introduction Name Company affiliation Title/function Job responsibility Database & Developer experience Your expectations.
The Type System1. 2.NET Type System The type system is the part of the CLR that defines all the types that programmers can use, and allows developers.
ITEC200 – Week03 Inheritance and Class Hierarchies.
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++
CS 2511 Fall Features of Object Oriented Technology  Abstraction Abstract class Interfaces  Encapsulation Access Specifiers Data Hiding  Inheritance.
Abstract Data Types and Encapsulation Concepts
Differences between C# and C++ Dr. Catherine Stringfellow Dr. Stewart Carpenter.
Object Oriented Software Development
Classes and Class Members Chapter 3. 3 Public Interface Contract between class and its clients to fulfill certain responsibilities The client is an object.
Overview of Previous Lesson(s) Over View  OOP  A class is a data type that you define to suit customized application requirements.  A class can be.
Module 7: Object-Oriented Programming in Visual Basic .NET
Introduction to Object Oriented Programming. Object Oriented Programming Technique used to develop programs revolving around the real world entities In.
BIM313 – Advanced Programming Techniques Object-Oriented Programming 1.
C# Programming Fundamentals of Object-Oriented Programming Fundamentals of Object-Oriented Programming Introducing Microsoft.NET Introducing Microsoft.NET.
Programming Pillars Introduction to Object- Oriented Programming.
Introduction to C# C# is - elegant, type-safe, object oriented language enabling to build applications that run on the.NET framework - types of applications.
Tuc Goodwin  Object and Component-Oriented Programming  Classes in C#  Scope and Accessibility  Methods and Properties  Nested.
C# EMILEE KING. HISTORY OF C# In the late 1990’s Microsoft recognized the need to be able to develop applications that can run on multiple operating system.
Object Oriented Software Development
Module 10: Inheritance in C#. Overview Deriving Classes Implementing Methods Using Sealed Classes Using Interfaces Using Abstract Classes.
Chapter 6 Introduction to Defining Classes. Objectives: Design and implement a simple class from user requirements. Organize a program in terms of a view.
CIS162AD Inheritance Part 3 09_inheritance.ppt. CIS162AD2 Overview of Topics  Inheritance  Virtual Methods used for Overriding  Abstract Classes and.
Object-Oriented Programming Chapter Chapter
1 OOP - An Introduction ISQS 6337 John R. Durrett.
1 9/6/05CS360 Windows Programming CS360 Windows Programming.
UMass Lowell Computer Science Java and Distributed Computing Prof. Karen Daniels Fall, 2000 Lecture 9 Java Fundamentals Objects/ClassesMethods Mon.
ISBN Object-Oriented Programming Chapter Chapter
PROGRAMMING IN C#. Collection Classes (C# Programming Guide) The.NET Framework provides specialized classes for data storage and retrieval. These classes.
Introduction to Object-Oriented Programming Lesson 2.
Object Oriented Software Development 4. C# data types, objects and references.
1 Chapter 11 © 1998 by Addison Wesley Longman, Inc The Concept of Abstraction - The concept of abstraction is fundamental in programming - Nearly.
Object Oriented Programming Session # 03.  Abstraction: Process of forming of general and relevant information from a complex scenarios.  Encapsulation:
CHARLES UNIVERSITY IN PRAGUE faculty of mathematics and physics C# Language &.NET Platform 4 th Lecture Pavel Ježek
Object Oriented Programming. OOP  The fundamental idea behind object-oriented programming is:  The real world consists of objects. Computer programs.
Presented by Ted Higgins, SQL Server DBA An Introduction to Object – Oriented Programming.
- This slide is intentionally left blank - Some of the slides are based on University of Linz.NET presentations. © University of Linz, Institute for System.
1 C# - Inheritance and Polymorphism. 2 1.Inheritance 2.Implementing Inheritance in C# 3.Constructor calls in Inheritance 4.Protected Access Modifier 5.The.
This In Java, the keyword this allows an object to refer to itself. Or, in other words, this refers to the current object – the object whose method or.
CHARLES UNIVERSITY IN PRAGUE faculty of mathematics and physics C# Language &.NET Platform 7 th Lecture Pavel Ježek
C# Fundamentals An Introduction. Before we begin How to get started writing C# – Quick tour of the dev. Environment – The current C# version is 5.0 –
Value Types. 2 Objectives Discuss concept of value types –efficiency –memory management –value semantics –boxing –unboxing –simple types Introduce struct.
Creating and Using Objects, Exceptions, Strings
Classes (Part 1) Lecture 3
C# - OOP TTU IT College , Autumn SEMESTER Andres käver.
2.7 Inheritance Types of inheritance
Inheritance and Polymorphism
Review: Two Programming Paradigms
11.1 The Concept of Abstraction
Microsoft .NET 3. Language Innovations Pan Wuming 2017.
Inheritance Modern object-oriented (OO) programming languages provide 3 capabilities: encapsulation inheritance polymorphism which can improve the design,
Structs.
CS360 Windows Programming
Lecture 23 Polymorphism Richard Gesick.
.NET and .NET Core 5.2 Type Operations Pan Wuming 2016.
Module 4: Implementing Object-Oriented Programming Techniques in C#
Lecture 22 Inheritance Richard Gesick.
Object-Oriented Programming
Abstract Classes and Interfaces
CIS 199 Final Review.
Java Programming Language
5. 3 Coding with Denotations
Lecture 10 Concepts of Programming Languages
- This slide is intentionally left blank -
C# Language & .NET Platform 9th Lecture
11.1 The Concept of Abstraction
5. OOP OOP © 2003 Microsoft.
Presentation transcript:

Module 5: Common Type System

Overview An Introduction to the Common Type System Elements of the Common Type System Object-Oriented Characteristics

An Introduction to the Common Type System Common Type System Architecture Value Types vs. Reference Types

Common Type System Architecture CLR Type System Value Types (System.ValueType) Fields Methods Properties Reference Types (System.Object) Built-in Types Primitive Types Delegates Built-in Types User-defined Value and Reference Types Interface Types Contract specifying method and property signature

Value Types vs. Reference Types Value Types Are Primitive or User-Defined Structures Allocated on stack Assigned as copies Default behavior is pass by value Reference Types Are Objects That Are: Allocated on heap using the new keyword Assigned as references Passed by reference

Elements of the Common Type System Primitive Types Objects Constructors Properties Custom Types Enumerations Interfaces

Primitive Types Simple Small Types Common in Most Languages Naming Differences C# Support Conversions

Objects Every Class Inherits from System.Object Objects Specify Data and Behavior Fields Define the Data Methods Define the Behavior class Accumulator { public float Result; public void Add(float amount) Result += amount; }

Constructors Constructors Are Used to Initialize Classes Constructors Can Have Zero or More Parameters class Rectangle { private int x1,y1,x2,y2; public Rectangle(int x1, int y1, int x2,int y2) this.x1 = x1; this.x2 = x2; this.y1 = y1; this.y2 = y2; }

Properties Properties Are Similar to Fields Properties Use get and set Accessor Methods for Managing Data Values public float Start { get return start; } set if (start >= 0) start = value;

Custom Types Inherit from System.ValueType Are Defined with the struct Keyword in C# Can Have Methods, Properties, and Fields struct Employee { public string Name; public ushort Age; public DateTime HireDate; public float Tenure() TimeSpan ts = DateTime.Now – HireDate; return ts.Days/(float)365; }

Enumerations .NET Framework Enumerations Inherit from System.Enum Use the enum keyword Bit Flags enum SeatPreference : ushort { Window, //Assigned value 0 Center, //Assigned value 1 Aisle //Assigned value 2 }

Interfaces An Interface Is a Contractual Description of Methods and Properties An Interface Has No Implementation Use Casting in Client Code to Use an Interface interface ICDPlayer { void Play(short playTrackNum); void Pause(); void Skip(short numTracks); short CurrentTrack get; set; }

Object-Oriented Characteristics Abstraction Encapsulation Inheritance Polymorphism

Abstraction Abstraction Works from the Specific to the General Grouping Elements Makes It Easier to Work with Complex Data Types Abstraction Is Supported Through Classes

Encapsulation Encapsulation Is the Process of Hiding Internal Details of a Class Encapsulation Keywords public protected internal private Type-Level Accessibility Nested Classes

Inheritance Inheritance Is the Reuse of Class Members in Other Classes The Common Type System Only Supports Single Inheritance for Classes Member Hiding Redefine the same method in the derived class Use the new keyword Abstract Members Sealed Classes

Polymorphism Polymorphism Allows a Reference Variable to Call the Correct Method Virtual Methods Enable Polymorphism in the Common Type System Use the virtual keyword in the base class Use the override keyword in the derived class Sealed Methods

Lab 5: Building Simple Types

Review An Introduction to the Common Type System Elements of the Common Type System Object-Oriented Characteristics