Implimentering af IComparable interfacet class Cirkel: IComparable { private long radius; // object memory :::::::::::::::::::::::::::::::::::::: #region.

Slides:



Advertisements
Similar presentations
ax2 + bx + c 2x2 + 11x + 5 ac 2(5) = b =11 ( ) 2x2 + 10x + 1x
Advertisements

1 Visual C# "Whidbey": Language Enhancements Anders Hejlsberg Distinguished Engineer Microsoft Corporation Anders Hejlsberg Distinguished.
12 Copyright © 2005, Oracle. All rights reserved. Structuring Code Using Abstract Classes and Interfaces.
VB List(Of type) A List can be thought of as an array that automatically adjusts its size as elements are added and removed A List may hold only objects.
Lists, Stacks, Queues Svetlin Nakov Telerik Corporation
ArrayLists The lazy mans array. Whats the matter here? int[] list = new int[10]; list[0] = 5; list[2] = hey; list[3] = 15; list[4] = 23;
Dictionaries, Hash Tables, Collisions Resolution, Sets Svetlin Nakov Telerik Corporation
1 / / / /. 2 (Object) (Object) –, 10 (Class) (Class) –, –, – (Variables) [ Data member Field Attribute](, ) – (Function) [ Member function Method Operation.
For(int i = 1; i
Execute Blocks of Code Multiple Times Svetlin Nakov Telerik Corporation
CS 141 Computer Programming 1 1 Arrays. Outline  Introduction  Arrays  Declaring Arrays  Examples Using Arrays  Sorting Arrays  Multiple-Subscripted.
Equations of Circles. Equation of a Circle The center of a circle is given by (h, k) The radius of a circle is given by r The equation of a circle in.
Samlingsklasser Istället för vektorer ArrayList Hashtable Mer om sorteringar.
LINQ and Collections An introduction to LINQ and Collections.
static void Main() { int i = 0; if (i == 0) { int a = 5; int b = 15; if (a == 5) { int c = 3; int d = 99; }
Typeparametrisering Generel kode (generisk kode).
Copyright  Hannu Laine C++-programming Part 8 Hannu Laine.
Execute Blocks of Code Multiple Times Telerik Software Academy C# Fundamentals – Part 1.
CHARLES UNIVERSITY IN PRAGUE faculty of mathematics and physics C# Language &.NET Platform 12 th -13 th Lecture Pavel Ježek.
1 Chapter 11 Introducing the Class Pages ( )
Fraction class class fraction { int num, den; fraction (int a, int b){ int common = gcd(a,b); num=a/common; den=b/common; } fraction (int a){ num=a; den=1;
1 Generic Collections Chapter Objectives You will be able to Use generic collection classes available in the.NET framework.
Computer Science 209 Software Development Equality and Comparisons.
Static Members, Structures, Enumerations, Generic Classes, Namespaces Learning & Development Team Telerik Software Academy.
Copyright © 2012 Pearson Education, Inc. Chapter 9 Delegates and Events.
C#: Udtryk og metoder. Indhold “With regards to programming statements and methods, C# offers what you would come to expect from a modern OOPL…” Udtryk.
FEN KbP: Seminar 2/JML-Intro1 JML Introduktion Specifikation af en Personklasse.
Paradigmer i Programmering 4 a. Java 1.5 -Generics -Autoboxing/unboxing -New for sætning -Static imports -enum.
Arrays Session 05 Mata kuliah: M0874 – Programming II Tahun: 2010.
S: Application of quicksort on an array of ints: partitioning.
Презентація за розділом “Гумористичні твори”
Центр атестації педагогічних працівників 2014
Галактики і квазари.
Характеристика ІНДІЇ.
Процюк Н.В. вчитель початкових класів Боярської ЗОШ І – ІІІ ст №4
CS 2511 Fall Features of Object Oriented Technology  Abstraction Abstract class Interfaces  Encapsulation Access Specifiers Data Hiding  Inheritance.
Selection Sort
BIM313 – Advanced Programming Techniques Object-Oriented Programming 1.
Духовні символи Голосіївського району
Selection Sort
Heaps and Heap Sorting Heaps implemented in an Array Heap Sorting.
Changing Comparison Programming in C# Changing Comparison CSE 494R (proposed course for 459 Programming in C#) Prof. Roger Crawfis.
Java Programming Persistent Data Types. Persistent Data Structure A persistent data structure is a data structure having an internal state that never.
Print Row Function void PrintRow(float x[ ][4],int i) { int j; for(j=0;j

C# Interfaces and RTTI CNS 3260 C#.NET Software Development.
Int fact (int n) { If (n == 0) return 1; else return n * fact (n – 1); } 5 void main () { Int Sum; : Sum = fact (5); : } Factorial Program Using Recursion.
Проф. д-р Васил Цанов, Институт за икономически изследвания при БАН
ЗУТ ПРОЕКТ на Закон за изменение и допълнение на ЗУТ
О Б Щ И Н А С И Л И С Т Р А П р о е к т Б ю д ж е т г.
Електронни услуги на НАП
Боряна Георгиева – директор на
РАЙОНЕН СЪД - БУРГАС РАБОТНА СРЕЩА СЪС СЪДЕБНИТЕ ЗАСЕДАТЕЛИ ПРИ РАЙОНЕН СЪД – БУРГАС 21 ОКТОМВРИ 2016 г.
Сътрудничество между полицията и другите специалисти в България
Съобщение Ръководството на НУ “Христо Ботев“ – гр. Елин Пелин
НАЦИОНАЛНА АГЕНЦИЯ ЗА ПРИХОДИТЕ
ДОБРОВОЛЕН РЕЗЕРВ НА ВЪОРЪЖЕНИТЕ СИЛИ НА РЕПУБЛИКА БЪЛГАРИЯ
Съвременни софтуерни решения
ПО ПЧЕЛАРСТВО ЗА ТРИГОДИШНИЯ
от проучване на общественото мнение,
Васил Големански Ноември, 2006
Програма за развитие на селските райони
ОПЕРАТИВНА ПРОГРАМА “АДМИНИСТРАТИВЕН КАПАЦИТЕТ”
БАЛИСТИКА НА ТЯЛО ПРИ СВОБОДНО ПАДАНЕ В ЗЕМНАТА АТМОСФЕРА
МЕДИЦИНСКИ УНИВЕРСИТЕТ – ПЛЕВЕН
Стратегия за развитие на клъстера 2015
Моето наследствено призвание
Правна кантора “Джингов, Гугински, Кючуков & Величков”
Безопасност на движението
-.&- ·Af& Q 0 "i'/
Presentation transcript:

Implimentering af IComparable interfacet class Cirkel: IComparable { private long radius; // object memory :::::::::::::::::::::::::::::::::::::: #region IComparable Members // returner < 0 hvis this er mindst // returner 0 hvis ens // returner > 0 hvis this er størst public int CompareTo(object obj) { return (int)(this.radius - (obj as Cirkel).radius); } #endregion }

Brug af IComparable interfacet til sortering Console.WriteLine("\nstatic void AfprøvCirkelSortering()"); List l = new List (); l.Add(new Cirkel(10)); l.Add(new Cirkel(11)); l.Add(new Cirkel(9)); l.Add(new Cirkel(8)); l.Add(new Cirkel(20)); Console.WriteLine("\nListen som den er"); foreach (Cirkel c in l) { Console.WriteLine("Radius:" + c.Radius); Console.WriteLine("Omkreds:" + c.Omkreds()); Console.WriteLine("Areal:" + c.Areal()); } Console.WriteLine("\nListen sorteret og reverse"); l.Sort(); l.Reverse(); foreach (ICirkel c in l) { Console.WriteLine("Radius:" + c.Radius); Console.WriteLine("Omkreds:" + c.Omkreds()); Console.WriteLine("Areal:" + c.Areal()); }

Brug af IComparable interfacet til sortering Console.WriteLine("\nListen kopiet til array og sorteret"); Cirkel[] ac = l.ToArray(); Array.Sort(ac); foreach (Cirkel c in ac) { Console.WriteLine("Radius:" + c.Radius); Console.WriteLine("Omkreds:" + c.Omkreds()); Console.WriteLine("Areal:" + c.Areal()); }