Prirejanje in preverjanje tipov

Similar documents
C++\CLI. Jim Fawcett CSE687-OnLine Object Oriented Design Summer 2017

Osnove algoritmov in podatkovnih struktur I (OAPS I)

Introduction to Programming Microsoft.NET Applications with Visual Studio 2008 (C#)

Državni izpitni center SPOMLADANSKI IZPITNI ROK *M * NAVODILA ZA OCENJEVANJE. Četrtek, 2. junij 2016 SPLOŠNA MATURA

Programming in Visual Basic with Microsoft Visual Studio 2010

Introduction to Programming Using Java (98-388)

C#: framework overview and in-the-small features

PROGRAMMING IN VISUAL BASIC WITH MICROSOFT VISUAL STUDIO Course: 10550A; Duration: 5 Days; Instructor-led

Programski jezik Java

Saikat Banerjee Page 1

Exceptions, Case Study-Exception handling in C++.

Object-Oriented Programming

MCSA Universal Windows Platform. A Success Guide to Prepare- Programming in C# edusum.com

DC69 C# &.NET DEC 2015

B.E /B.TECH DEGREE EXAMINATIONS,

Hierarchical inheritance: Contains one base class and multiple derived classes of the same base class.

Introduction to C++ Introduction. Structure of a C++ Program. Structure of a C++ Program. C++ widely-used general-purpose programming language

Osnove programskog jezika C# Čas 5. Delegati, događaji i interfejsi

Abstrakcije v modelih in jezikih

Test iz programskog jezika C# - ASP Izaberite tačan odgovor. Student's name : Programiranje ASP C# 1) A local variable

Introduction to C++ with content from

FINALTERM EXAMINATION Spring 2009 CS506- Web Design and Development Solved by Tahseen Anwar


The C# Programming Language. Overview

Short Notes of CS201

CS/B.TECH/CSE(New)/SEM-5/CS-504D/ OBJECT ORIENTED PROGRAMMING. Time Allotted : 3 Hours Full Marks : 70 GROUP A. (Multiple Choice Type Question)

CS201 - Introduction to Programming Glossary By

Organizacija računalnikov (OR) UNI-RI, 3.l. RS Vaje. doc.dr. Mira Trebar

Program Correctness and Efficiency. Chapter 2

Exceptions in Java

20 Most Important Java Programming Interview Questions. Powered by

Objectives for this class meeting. 1. Conduct review of core concepts concerning contracts and pre/post conditions

DOT NET Syllabus (6 Months)

C# 6.0 in a nutshell / Joseph Albahari & Ben Albahari. 6th ed. Beijin [etc.], cop Spis treści

Zhifu Pei CSCI5448 Spring 2011 Prof. Kenneth M. Anderson

Course Hours

Programming II (CS300)

Access and Non access Modifiers in Core Java Core Java Tutorial

1 Shyam sir JAVA Notes

104. Intermediate Java Programming

BM214E Object Oriented Programming Lecture 4

Index. Index. More information. block statements 66 y 107 Boolean 107 break 55, 68 built-in types 107

Kakadu and Java. David Taubman, UNSW June 3, 2003

Noopur Gupta Eclipse JDT/UI Committer IBM India

Programming II (CS300)

CS506 Web Design & Development Final Term Solved MCQs with Reference

Java Training For Six Weeks

VISUAL PROGRAMMING_IT0309 Semester Number 05. G.Sujatha & R.Vijayalakshmi Assistant professor(o.g) SRM University, Kattankulathur

University of West Bohemia in Pilsen. Faculty of Applied Sciences. Department of Computer Science and Engineering DIPLOMA THESIS

Understanding delegates

CS Exam 1 Review Suggestions

Synchronization SPL/2010 SPL/20 1

ADVANTAGES. Via PL/SQL, all sorts of calculations can be done quickly and efficiently without use of Oracle engine.

.NET Advance Package Syllabus

Absolute C++ Walter Savitch

Murach s Beginning Java with Eclipse

INTRODUCTION TO.NET. Domain of.net D.N.A. Architecture One Tier Two Tier Three Tier N-Tier THE COMMON LANGUAGE RUNTIME (C.L.R.)

OVERVIEW ENVIRONMENT PROGRAM STRUCTURE BASIC SYNTAX DATA TYPES TYPE CONVERSION

Microsoft Visual C# Step by Step. John Sharp

Computer Organization & Assembly Language Programming

Exception Namespaces C Interoperability Templates. More C++ David Chisnall. March 17, 2011

TradeInterceptor SDK Quick Start Guide

DESIGNING, CODING, AND DOCUMENTING

Introduction. Chapter 1:

Developing Microsoft.NET Applications for Windows (Visual Basic.NET)

Certification In Java Language Course Course Content

Object Oriented Programming Exception Handling

B2.52-R3: INTRODUCTION TO OBJECT ORIENTATED PROGRAMMING THROUGH JAVA

Object-Oriented Programming in C# (VS 2015)

Casting -Allows a narrowing assignment by asking the Java compiler to "trust us"

CS365 Midterm -- Spring 2019

Chapter 12: How to Create and Use Classes

Contents. Figures. Tables. Examples. Foreword. Preface. 1 Basics of Java Programming 1. xix. xxi. xxiii. xxvii. xxix

Development tools: Version control, build tools, and integrated development environments 1

Contents. About This Book...1

J2EE Development. Course Detail: Audience. Duration. Course Abstract. Course Objectives. Course Topics. Class Format.

Java Programming Constructs Java Programming 2 Lesson 1

Course Description. Learn To: : Intro to JAVA SE7 and Programming using JAVA SE7. Course Outline ::

The Chirp Language Specification

Application Development in JAVA. Data Types, Variable, Comments & Operators. Part I: Core Java (J2SE) Getting Started

Documenting Lucene.Net

Lecture 5: Methods CS2301

Creating delegate, actually creating an object that can hold a reference to a method.

PESIT Bangalore South Campus

Supports 1-1, 1-many, and many to many relationships between objects

Designing and Writing a Program. Divide and Conquer! The Design-Code-Debug Cycle. Documentation is Code. Pair Programming 3/8/2012

CS 151. Exceptions & Javadoc. slides available on course website. Sunday, September 9, 12

Overview of Eclipse Lectures. Module Road Map

PREDMET. Osnove Java Programiranja. Čas JAVADOC

Designing your BI Architecture

Java SE7 Fundamentals

Java Exceptions Version June 2009

OHF ATNA Audit Client. Architecture & API Documentation. Version seknoop[at]us[dot]ibm[dot]com Sarah Knoop

Page 1

Table of Contents Preface Bare Necessities... 17

Types. Type checking. Why Do We Need Type Systems? Types and Operations. What is a type? Consensus

(2½ hours) Total Marks: 75

User Defined Functions

Vodnik skozi Google Analytics Beta verzija 1. del. prehod s stare kode (urchin.js), k novi kodi za sledenje (ga.js)

Problem Solving with C++

Transcription:

Uvod v C# Drugi del

Dedovanje

Sintaksa

Prirejanje in preverjanje tipov

Kaste preverjenih tipov

Prekrivanje metod

Dinamično povezovanje (poenostavljeno)

Skrivanje

Dinamično povezovanje (s skrivanjem)

Fragile base class problem

Konstruktorji in dedovanje

Vidnost protected in internal

Abstraktni razredi

Abstraktne lastnosti in indekserji

Zapečateni razredi

Vmesniki (interfaces)

Sintaksa

Implementacija vmesnikov

Delo z vmesniki

Primer

Delegati in dogodki

Delegati Delegates are reference types which allow indirect calls to methods. A delegate instance holds references to some number of methods, and by invoking the delegate one causes all of these methods to be called. The usefulness of delegates lies in the fact that the functions which invoke them are blind to the underlying methods they thereby cause to run (see, for instance, the discussion of events, below).

Delegati From this brief description, it can be seen that delegates are functionally rather similar to C++'s 'function pointers'. However, it is important to bear in mind two main differences. Firstly, delegates are reference types rather than value types. Secondly, some single delegates can reference multiple methods

Delegate Declaration and Instantiation Each delegate is limited to referencing methods of a particular kind only. The type is indicated by the delegate declaration - the input parameters and return type given in the delegate declaration must be shared by the methods its delegate instances reference. To illustrate this: a delegate specified as below can be used to refer only to methods which have a single String input and no return value: public delegate void Print (String s);

Suppose, for instance, that a class contains the following method: public void realmethod (String mystring) { // method code } Another method in this class could then instantiate the 'Print' delegate in the following way, so that it holds a reference to 'realmethod': Print delegatevariable = new Print(realMethod);

Razredi - dogodki Jezikovna podpora dogodkom Ključna beseda event nam omogoča določiti delegata, ki bo ustrezal poklicanim metodam ob nastopu nekega dogodka. public event AlarmEventHandler Alarm; Dogodek sprožimo s klicem dogodka Alarm(); Odjemalci se prijavijo na dogodek z operatorjem += eventsource.alarm += new AlarmEventHandler(eventListener.AlarmRang);

Deklaracija delegata, prireditev metode delegatu

Prirejanje različnih metod

Creating a delegate value

Multicast delegati

Events = Special Delegate Variables

Izjeme (exceptions)

Stavek try

System.Exception

Throwing an Exception

Hierarhija izjem

Searching for a catch Clause

No Throws Clause in Method Signature

Namespaces and Assemblies

C# Namespaces vs. Java Packages

Namespaces vs. Packages (continued)

Assemblies

Kako se tvorijo assemblies

Opcije prevajalnika

Opcije prevajalnika

Primeri prevajanj

Atributi

Atributi Atributi so deklarativni elementi jezika pridevniki so na primer tudi deklarativni elementi omogočajo dekoracijo elementov kode z dodatno informacijo assembly, modul, tip, član tipa, return value, parameter Atributi posplošujejo koncept deklarativnega elementa atributi niso omejeni na vnaprej določeno množico lahko se zmišljujemo svoje nove atribute atributi in njihove vrednosti so dosegljivi v času prevajanja in v času izvajanja [Obsolete("This class is obsolete")] class A { public void F() {} }

Atributi

Atribut s parametri

Atributi Nekateri vnaprej definirani atributi Ime atributa Opis Browsable Vključenost lastnosti v okno lastnosti Serializable Določa naj bo razred ali struktura serializabilna Obsolete Določa, da je nek element kode zastarel Conditional Določa vključenost metode v odvisnosti od predproc. simbola

Atributi Zgled uporabe atributa Conditional #define Debug public class Debug { [Conditional("Debug")] public static void Assert(bool cond, String s) { if (!cond) { throw new AssertionException(s); } } void DoSomething() {... // If Debug is not defined, the next line is // not even called Assert((x == y), X should equal Y );... } }

Še en primer: atribut Conditional

Tvoji lastni atributi

Niti (threads)

Sodelujoče niti (participating threads)

Primer

Stanja niti

Primer za Join

Medsebojno izobčenje (sinhronizacija)

Razred Monitor

Wait in Pulse

Primer: sinhroniziran medpomnilnik

Komentarji XML

Posebni komentarji (podobno javadoc)

Primer komentirane kode

Tvorjena XML datoteka

XML oznake (XML tags)

Povzetek C#

Odprtokodni c# MCS: The Ximian C# compiler The Mono C# compiler is considered feature C# 1.0 complete at this point and mature. MCS is able to compile itself and many more C# programs (there is a test suite included that you can use). It is routinely used to compile Mono, roughly 1.7 million lines of C# code. The compiler is also fairly fast. On a IBM ThinkPad t40 it compiles 18,000 lines of C# code per second. Work on C# 2.0 has started: some pieces of it are available on the standard compiler with the -2 switch (iterators, method conversions) and some others are available on the `gmcs' branch on CVS (generics) Obtaining MCS The Mono C# compiler is part of the `mcs' module in the Mono CVS you can get it from our Anonymous CVS server, or you can get nightly download page.

Mono razhroščevalnik

Eclipse in mono