Object-Oriented Programming with C# |
Английская грамматика | ||
<< Андрагогика – теоретическая основа методической работы | Сomplex object >> |
Автор: Svetlin Nakov. Чтобы познакомиться с картинкой полного размера, нажмите на её эскиз. Чтобы можно было использовать все картинки для урока английского языка, скачайте бесплатно презентацию «Object-Oriented Programming with C#.pptx» со всеми картинками в zip-архиве размером 3395 КБ.
Сл | Текст | Сл | Текст |
1 | Object-Oriented Programming with C#. | 50 | Console.WriteLine(str); } }. |
Classes, Constructors, Properties, Events, | 51 | Using Anonymous Methods. The same | |
Static Members, Interfaces, Inheritance, | thing can be accomplished by using an | ||
Polymorphism. Doncho Minkov. Technical | anonymous method: class SomeClass { | ||
Trainer. Telerik Corporation. | delegate void SomeDelegate(string str); | ||
www.telerik.com. | public void InvokeMethod() { SomeDelegate | ||
2 | Table of Contents. Defining Classes | dlg = delegate(string str) { | |
Access Modifiers Constructors Fields, | Console.WriteLine(str); }; | ||
Constants and Properties Static Members | dlg("Hello"); } }. | ||
Structures Delegates and Events Interfaces | 52 | Events. In component-oriented | |
Inheritance Polymorphism. | programming the components send events to | ||
3 | OOP and .NET. In .NET Framework the | their owner to notify them when something | |
object-oriented approach has roots in the | happens E.g. when a button is pressed an | ||
deepest architectural level All .NET | event is raised The object which causes an | ||
applications are object-oriented All .NET | event is called event sender The object | ||
languages are object-oriented The class | which receives an event is called event | ||
concept from OOP has two realizations: | receiver In order to be able to receive an | ||
Classes and structures There is no | event the event receivers must first | ||
multiple inheritance in .NET Classes can | "subscribe for the event" | ||
implement several interfaces at the same | 53 | Events in .NET. In the component model | |
time. | of .NET Framework delegates and events | ||
4 | Defining Classes. | provide mechanism for: Subscription to an | |
5 | Classes in OOP. Classes model | event Sending an event Receiving an event | |
real-world objects and define Attributes | Events in C# are special instances of | ||
(state, properties, fields) Behavior | delegates declared by the C# keyword event | ||
(methods, operations) Classes describe | Example (Button.Click): public event | ||
structure of objects Objects describe | EventHandler Click; | ||
particular instance of a class Properties | 54 | Events in .NET (2). The C# compiler | |
hold information about the modeled object | automatically defines the += and -= | ||
relevant to the problem Operations | operators for events += subscribe for an | ||
implement object behavior. | event -= unsubscribe for an event There | ||
6 | Classes in C#. Classes in C# could | are no other allowed operations Example: | |
have following members: Fields, constants, | Button button = new | ||
methods, properties, indexers, events, | Button("OK"); button.Click += | ||
operators, constructors, destructors Inner | delegate { Console.WriteLine("Button | ||
types (inner classes, structures, | clicked."); }; | ||
interfaces, delegates, ...) Members can | 55 | Events vs. Delegates. Events are not | |
have access modifiers (scope) public, | the same as member fields of type delegate | ||
private, protected, internal Members can | The event is processed by a delegate | ||
be static (common) or specific for a given | Events can be members of an interface | ||
object. 6. | unlike delegates Calling of an event can | ||
7 | Simple Class Definition. Begin of | only be done in the class it is defined in | |
class definition. Inherited (base) class. | By default the access to the events is | ||
Fields. Constructor. Property. public | synchronized (thread-safe). ? public | ||
class Cat : Animal { private string name; | MyDelegate m; public event MyDelegate m; | ||
private string owner; public Cat(string | 56 | System.EventHandler Delegate. Defines | |
name, string owner) { this.name = name; | a reference to a callback method, which | ||
this.owner = owner; } public string Name { | handles events No additional information | ||
get { return name; } set { name = value; } | is sent Used in many occasions internally | ||
}. | in .NET E.g. in ASP.NET and Windows Forms | ||
8 | Simple Class Definition (2). Method. | The EventArgs class is base class with no | |
End of class definition. public string | information about the event Sometimes | ||
Owner { get { return owner;} set { owner = | delegates derive from it. public delegate | ||
value; } } public void SayMiau() { | void EventHandler( Object sender, | ||
Console.WriteLine("Miauuuuuuu!") | EventArgs e); | ||
} }. | 57 | EventHandler – Example. public class | |
9 | Class Definition and Members. Class | Button { public event EventHandler Click; | |
definition consists of: Class declaration | public event EventHandler GotFocus; public | ||
Inherited class or implemented interfaces | event EventHandler TextChanged; ... } | ||
Fields (static or not) Constructors | public class ButtonTest { private static | ||
(static or not) Properties (static or not) | void Button_Click(object sender, EventArgs | ||
Methods (static or not) Events, inner | eventArgs) { Console.WriteLine("Call | ||
types, etc. | Button_Click() event"); } public | ||
10 | Access Modifiers. Public, Private, | static void Main() { Button button = new | |
Protected, Internal. | Button(); button.Click += Button_Click; } | ||
11 | Access Modifiers. Class members can | }. | |
have access modifiers Used to restrict the | 58 | Interfaces and Abstract Classes. | |
classes able to access them Supports the | 59 | Interfaces. Describe a group of | |
OOP principle "encapsulation" | methods (operations), properties and | ||
Class members can be: public – accessible | events Can be implemented by given class | ||
from any class protected – accessible from | or structure Define only the methods’ | ||
the class itself and all its descendent | prototypes No concrete implementation Can | ||
classes private – accessible from the | be used to define abstract data types Can | ||
class itself only internal – accessible | not be instantiated Members do not have | ||
from the current assembly (used by | scope modifier and by default the scope is | ||
default). | public. | ||
12 | Defining Classes. Example. | 60 | Interfaces – Example. public interface |
13 | Task: Define Class Dog. Our task is to | IPerson { string Name // property Name { | |
define a simple class that represents | get; set; } DateTime DateOfBirth // | ||
information about a dog The dog should | property DateOfBirth { get; set; } int Age | ||
have name and breed If there is no name or | // property Age (read-only) { get; } }. | ||
breed assigned to the dog, it should be | 61 | Interfaces – Example (2). interface | |
named "Balkan" and its breed | IShape { void SetPosition(int x, int y); | ||
should be "Street excellent" It | int CalculateSurface(); } interface | ||
should be able to view and change the name | IMovable { void Move(int deltaX, int | ||
and the breed of the dog The dog should be | deltaY); } interface IResizable { void | ||
able to bark. | Resize(int weight); void Resize(int | ||
14 | Defining Class Dog – Example. public | weightX, int weightY); void ResizeByX(int | |
class Dog { private string name; private | weightX); void ResizeByY(int weightY); }. | ||
string breed; public Dog() { this.name = | 62 | Interface Implementation. Classes and | |
"Balkan"; this.breed = | structures can implement (support) one or | ||
"Street excellent"; } public | many interfaces Interface realization must | ||
Dog(string name, string breed) { this.name | implement all its methods If some methods | ||
= name; this.breed = breed; } //(example | do not have implementation the class or | ||
continues). | structure have to be declared as an | ||
15 | Defining Class Dog – Example (2). | abstract. | |
public string Name { get { return name; } | 63 | Interface Implementation – Example. | |
set { name = value; } } public string | class Rectangle : IShape, IMovable { | ||
Breed { get { return breed; } set { breed | private int x, y, width, height; public | ||
= value; } } public void SayBau() { | void SetPosition(int x, int y) // IShape { | ||
Console.WriteLine("{0} said: | this.x = x; this.y = y; } public int | ||
Bauuuuuu!", name); } }. | CalculateSurface() // IShape { return | ||
16 | Using Classes and Objects. | this.width * this.height; } public void | |
17 | Using Classes. How to use classes? | Move(int deltaX, int deltaY) // IMovable { | |
Create a new instance Access the | this.x += deltaX; this.y += deltaY; } }. | ||
properties of the class Invoke methods | 64 | Abstract Classes. Abstract method is a | |
Handle events How to define classes? | method without implementation Left empty | ||
Create new class and define its members | to be implemented by descendant classes | ||
Create new class using some other as base | When a class contains at least one | ||
class. | abstract method, it is called abstract | ||
18 | How to Use Classes (Non-static)? | class Mix between class and interface | |
Create an instance Initialize fields | Inheritors are obligated to implement | ||
Manipulate instance Read / change | their abstract methods Can not be directly | ||
properties Invoke methods Handle events | instantiated. | ||
Release occupied resources Done | 65 | Abstract Class – Example. abstract | |
automatically in most cases. | class MovableShape : IShape, IMovable { | ||
19 | Task: Dog Meeting. Our task is as | private int x, y; public void Move(int | |
follows: Create 3 dogs First should be | deltaX, int deltaY) { this.x += deltaX; | ||
named “Sharo”, second – “Rex” and the last | this.y += deltaY; } public void | ||
– left without name Add all dogs in an | SetPosition(int x, int y) { this.x = x; | ||
array Iterate through the array elements | this.y = y; } public abstract int | ||
and ask each dog to bark Note: Use the Dog | CalculateSurface(); }. | ||
class from the previous example! | 66 | Cohesion and Coupling. | |
20 | Dog Meeting – Example. static void | 67 | Cohesion. Cohesion describes how |
Main() { Console.WriteLine("Enter | closely all the routines in a class or all | ||
first dog's name: "); dogName = | the code in a routine support a central | ||
Console.ReadLine(); | purpose Cohesion must be strong Classes | ||
Console.WriteLine("Enter first dog's | must contain strongly related | ||
breed: "); dogBreed = | functionality and aim for single purpose | ||
Console.ReadLine(); // Using the Dog | Cohesion is a useful tool for managing | ||
constructor to set name and breed Dog | complexity Well-defined abstractions keep | ||
firstDog = new Dog(dogName, dogBreed); Dog | cohesion strong. | ||
secondDog = new Dog(); | 68 | Good and Bad Cohesion. Good cohesion: | |
Console.WriteLine("Enter second dog's | hard disk, CD-ROM, floppy BAD: spaghetti | ||
name: "); dogName = | code. | ||
Console.ReadLine(); | 69 | Strong Cohesion. Strong cohesion | |
Console.WriteLine("Enter second dog's | example Class Math that has methods: | ||
breed: "); dogBreed = | Sin(), Cos(), Asin(), Sqrt(), Pow(), Exp() | ||
Console.ReadLine(); // Using properties to | Math.PI, Math.E. double sideA = 40, sideB | ||
set name and breed secondDog.Name = | = 69; double angleAB = Math.PI / 3; double | ||
dogName; secondDog.Breed = dogBreed; }. | sideC = Math.Pow(sideA, 2) + | ||
21 | Constructors. Defining and Using Class | Math.Pow(sideB, 2) - 2 * sideA * sideB * | |
Constructors. | Math.Cos(angleAB); double sidesSqrtSum = | ||
22 | What is Constructor? Constructors are | Math.Sqrt(sideA) + Math.Sqrt(sideB) + | |
special methods Invoked when creating a | Math.Sqrt(sideC); | ||
new instance of an object Used to | 70 | Bad Cohesion. Example of bad cohesion | |
initialize the fields of the instance | Class Magic that has all these methods: | ||
Constructors has the same name as the | Another example: public void | ||
class Have no return type Can have | PrintDocument(Document d); public void | ||
parameters Can be private, protected, | SendEmail(string recipient, string | ||
internal, public. | subject, string text); public void | ||
23 | Defining Constructors. Class Point | CalculateDistanceBetweenPoints(int x1, int | |
with parameterless constructor: public | y1, int x2, int y2). | ||
class Point { private int xCoord; private | MagicClass.MakePizza("Fat | ||
int yCoord; // Simple default constructor | Pepperoni"); | ||
public Point() { xCoord = 0; yCoord = 0; } | MagicClass.WithdrawMoney("999e6" | ||
// More code ... }. | ; MagicClass.OpenDBConnection(); | ||
24 | Defining Constructors (2). As rule | 71 | Coupling. Coupling describes how |
constructors should initialize all own | tightly a class or routine is related to | ||
class fields. public class Person { | other classes or routines Coupling must be | ||
private string name; private int age; // | kept loose Modules must depend little on | ||
Default constructor public Person() { name | each other All classes and routines must | ||
= "[no name]"; age = 0; } // | have small, direct, visible, and flexible | ||
Constructor with parameters public | relations to other classes and routines | ||
Person(string name, int age) { this.name = | One module must be easily used by other | ||
name; this.age = age; } // More code ... | modules. | ||
}. | 72 | Loose and Tight Coupling. Loose | |
25 | Constructors and Initialization. Pay | Coupling: Easily replace old HDD Easily | |
attention when using inline | place this HDD to another motherboard | ||
initialization! public class ClockAlarm { | Tight Coupling: Where is the video | ||
private int hours = 9; // Inline | adapter? Can you change the video | ||
initialization private int minutes = 0; // | controller? | ||
Inline initialization // Default | 73 | Loose Coupling – Example. class Report | |
constructor public ClockAlarm() { } // | { public bool LoadFromFile(string | ||
Constructor with parameters public | fileName) {…} public bool | ||
ClockAlarm(int hours, int minutes) { | SaveToFile(string fileName) {…} } class | ||
this.hours = hours; // Invoked after the | Printer { public static int Print(Report | ||
inline this.minutes = minutes; // | report) {…} } class LooseCouplingExample { | ||
initialization! } // More code ... }. | static void Main() { Report myReport = new | ||
26 | Chaining Constructors Calls. Reusing | Report(); | |
constructors. public class Point { private | myReport.LoadFromFile("C:\\DailyRepor | ||
int xCoord; private int yCoord; public | .rep"); Printer.Print(myReport); } }. | ||
Point() : this(0,0) // Reuse constructor { | 74 | Tight Coupling – Example. class | |
} public Point(int xCoord, int yCoord) { | MathParams { public static double operand; | ||
this.xCoord = xCoord; this.yCoord = | public static double result; } class | ||
yCoord; } // More code ... }. | MathUtil { public static void Sqrt() { | ||
27 | Fields, Constants and and Properties. | MathParams.result = | |
28 | Fields. Fields contain data for the | CalcSqrt(MathParams.operand); } } class | |
class instance Can be arbitrary type Have | Example { static void Main() { | ||
given scope Can be declared with a | MathParams.operand = 64; MathUtil.Sqrt(); | ||
specific value. class Student { private | Console.WriteLine(MathParams.result); } }. | ||
string firstName; private string lastName; | 75 | Spaghetti Code. Combination of bad | |
private int course = 1; private string | cohesion and tight coupling. class Report | ||
speciality; protected Course[] | { public void Print() {…} public void | ||
coursesTaken; private string remarks = | InitPrinter() {…} public void | ||
"(no remarks)"; }. | LoadPrinterDriver(string fileName) {…} | ||
29 | Constants. Constant fields are defined | public bool SaveReport(string fileName) | |
like fields, but: Defined with const Must | {…} public void SetPrinter(string printer) | ||
be initialized at their definition Their | {…} } class Printer { public void | ||
value can not be changed at runtime. | SetFileName() {…} public static bool | ||
public class MathConstants { public const | LoadReport() {…} public static bool | ||
string PI_SYMBOL = "?"; public | CheckReport() {…} }. | ||
const double PI = 3.1415926535897932385; | 76 | Inheritance. | |
public const double E = | 77 | Inheritance. Inheritance is the | |
2.7182818284590452354; public const double | ability of a class to implicitly gain all | ||
LN10 = 2.30258509299405; public const | members from another class Inheritance is | ||
double LN2 = 0.693147180559945; }. | fundamental concept in OOP The class whose | ||
30 | Read-Only Fields. Initialized at the | methods are inherited is called base | |
definition or in the constructor Can not | (parent) class The class that gains new | ||
be modified further Defined with the | functionality is called derived (child) | ||
keyword readonly Represent runtime | class Inheritance establishes an is-a | ||
constants. public class ReadOnlyDemo { | relationship between classes: A is B. | ||
private readonly int size; public | 78 | Inheritance (2). All class members are | |
ReadOnlyDemo(int Size) { size = Size; // | inherited Fields, methods, properties, … | ||
can not be further modified! } }. | In C# classes could be inherited The | ||
31 | The Role of Properties. Expose | structures in C# could not be inherited | |
object's data to the outside world Control | Inheritance allows creating deep | ||
how the data is manipulated Properties can | inheritance hierarchies In .NET there is | ||
be: Read-only Write-only Read and write | no multiple inheritance, except when | ||
Give good level of abstraction Make | implementing interfaces. | ||
writing code easier. | 79 | How to Define Inheritance? We must | |
32 | Defining Properties in C#. Properties | specify the name of the base class after | |
should have: Access modifier (public, | the name of the derived In the constructor | ||
protected, etc.) Return type Unique name | of the derived class we use the keyword | ||
Get and / or Set part Can contain code | base to invoke the constructor of the base | ||
processing data in specific way. | class. public class Shape {...} public | ||
33 | Defining Properties – Example. public | class Circle : Shape {...}. public Circle | |
class Point { private int xCoord; private | (int x, int y) : base(x) {...}. | ||
int yCoord; public int XCoord { get { | 80 | Inheritance – Example. public class | |
return xCoord; } set { xCoord = value; } } | Mammal { private int age; public | ||
public int YCoord { get { return yCoord; } | Mammal(int age) { this.age = age; } public | ||
set { yCoord = value; } } // More code ... | int Age { get { return age; } set { age = | ||
}. | value; } } public void Sleep() { | ||
34 | Dynamic Properties. Properties are not | Console.WriteLine("Shhh! I'm | |
obligatory bound to a class field – can be | sleeping!"); } }. | ||
calculated dynamically: public class | 81 | Inheritance – Example (2). public | |
Rectangle { private float width; private | class Dog : Mammal { private string breed; | ||
float height; // More code ... public | public Dog(int age, string breed): | ||
float Area { get { return width * height; | base(age) { this.breed = breed; } public | ||
} } }. | string Breed { get { return breed; } set { | ||
35 | Automatic Properties. Properties could | breed = value; } } public void WagTail() { | |
be defined without an underlying field | Console.WriteLine("Tail | ||
behind them It is automatically created by | wagging..."); } }. | ||
the C# compiler. class UserProfile { | 82 | Inheritance – Example (3). static void | |
public int UserId { get; set; } public | Main() { // Create 5 years old mammal | ||
string FirstName { get; set; } public | Mamal mamal = new Mamal(5); | ||
string LastName { get; set; } } … | Console.WriteLine(mamal.Age); | ||
UserProfile profile = new UserProfile() { | mamal.Sleep(); // Create a bulldog, 3 | ||
FirstName = "Steve", LastName = | years old Dog dog = new | ||
"Balmer", UserId = 91112 }; 35. | Dog("Bulldog", 3); dog.Sleep(); | ||
36 | Static Members. Static vs. Instance | dog.Age = 4; Console.WriteLine("Age: | |
Members. | {0}", dog.Age); | ||
37 | Static Members. Static members are | Console.WriteLine("Breed: {0}", | |
associated with a type rather than with an | dog.Breed); dog.WagTail(); }. | ||
instance Defined with the modifier static | 83 | Polymorphism. | |
Static can be used for Fields Properties | 84 | Polymorphism. Polymorphism is | |
Methods Events Constructors. | fundamental concept in OOP The ability to | ||
38 | Static vs. Non-Static. Static: | handle the objects of a specific class as | |
Associated with a type, not with an | instances of its parent class and to call | ||
instance Non-Static: The opposite, | abstract functionality Polymorphism allows | ||
associated with an instance Static: | creating hierarchies with more valuable | ||
Initialized just before the type is used | logical structure Allows invoking abstract | ||
for the first time Non-Static: Initialized | functionality without caring how and where | ||
when the constructor is called. | it is implemented. | ||
39 | Static Members – Example. public class | 85 | Polymorphism (2). Polymorphism is |
SqrtPrecalculated { public const int | usually implemented through: Virtual | ||
MAX_VALUE = 10000; // Static field private | methods (virtual) Abstract methods | ||
static int[] sqrtValues; // Static | (abstract) Methods from an interface | ||
constructor private static | (interface) In C# to override virtual | ||
SqrtPrecalculated() { sqrtValues = new | method the keyword override is used C# | ||
int[MAX_VALUE + 1]; for (int i = 0; i < | allows hiding virtual methods in derived | ||
sqrtValues.Length; i++) { sqrtValues[i] = | classes by the keyword new. | ||
(int)Math.Sqrt(i); } } //(example | 86 | Polymorphism – Example. class Person { | |
continues). | public virtual void PrintName() { | ||
40 | Static Members – Example (2). // | Console.WriteLine("I am a | |
Static method public static int | person."); } } class Trainer : Person | ||
GetSqrt(int value) { return | { public override void PrintName() { | ||
sqrtValues[value]; } // The Main() method | Console.WriteLine("I am a | ||
is always static static void Main() { | trainer."); } } class Student : | ||
Console.WriteLine(GetSqrt(254)); } }. | Person { public override void PrintName() | ||
41 | Structures. | { Console.WriteLine("I am a | |
42 | Structures. Structures represent a | student."); } }. | |
combination of fields with data Look like | 87 | Polymorphism – Example (2). static | |
the classes, but are value types Their | void Main() { Person[] persons = { new | ||
content is stored in the stack Transmitted | Person(), new Trainer(), new Student() }; | ||
by value Destroyed when go out of scope | foreach (Person p in persons) { | ||
However classes are reference type and are | Console.WriteLine(p); } // I am a person. | ||
placed in the dynamic memory (heap) Their | // I am a trainer. // I am a student. }. | ||
creation and destruction is slower. | 88 | Homework. We are given a school. In | |
43 | Structures – Example. struct Point { | the school there are classes of students. | |
public int X, Y; } struct Color { public | Each class has a set of teachers. Each | ||
byte redValue; public byte greenValue; | teacher teaches a set of disciplines. | ||
public byte blueValue; } struct Square { | Students have name and unique class | ||
public Point location; public int size; | number. Classes have unique text | ||
public Color borderColor; public Color | identifier. Teachers have name. | ||
surfaceColor; }. | Disciplines have name, number of lectures | ||
44 | When to Use Structures? Use structures | and number of exercises. Both teachers and | |
To make your type behave as a primitive | students are people. Your task is to | ||
type If you create many instances and | identify the classes (in terms of OOP) and | ||
after that you free them – e.g. in a cycle | their attributes and operations, define | ||
Do not use structures When you often | the class hierarchy. 88. | ||
transmit your instances as method | 89 | Homework (2). Define class Human with | |
parameters If you use collections without | first name and last name. Define new class | ||
generics (too much boxing / unboxing!). | Student which is derived from Human and | ||
45 | Delegates and Events. | has new field – grade. Define class Worker | |
46 | What are Delegates? Delegates are | derived from Human with new field | |
reference types Describe the signature of | weekSalary and work-hours per day and | ||
a given method Number and types of the | method MoneyPerHour() that returns money | ||
parameters The return type Their | earned by hour by the worker. Define the | ||
"values" are methods These | proper constructors and properties for | ||
methods correspond to the signature of the | this hierarchy. Initialize an array of 10 | ||
delegate. | students and sort them by grade in | ||
47 | What are Delegates? (2). Delegates are | ascending order. Initialize an array of 10 | |
roughly similar to function pointers in C | workers and sort them by money per hour in | ||
and C++ Contain a strongly-typed pointer | descending order. 89. | ||
(reference) to a method They can point to | 90 | Homework (3). Define abstract class | |
both static or instance methods Used to | Shape with only one abstract method | ||
perform callbacks. | CalculateSurface() and fields width and | ||
48 | Delegates – Example. // Declaration of | height. Define two new classes Triangle | |
a delegate public delegate void | and Rectangle that implement the virtual | ||
simpledelegate(string param); public class | method and return the surface of the | ||
testdelegate { public static void | figure (height*width for rectangle and | ||
testfunction(string param) { | height*width/2 for triangle). Define class | ||
console.Writeline("i was called by a | Circle and suitable constructor so that on | ||
delegate."); | initialization height must be kept equal | ||
Console.Writeline("i got parameter | to width and implement the | ||
{0}.", Param); } public static void | CalculateSurface() method. Write a program | ||
main() { // instantiation of а delegate | that tests the behavior of the | ||
simpledelegate simpledelegate = new | CalculateSurface() method for different | ||
simpledelegate(testfunction); // | shapes (Circle, Rectangle, Triangle) | ||
invocation of the method, pointed by a | stored in an array. 90. | ||
delegate simpledelegate("test"); | 91 | Homework (4). Create a hierarchy Dog, | |
} }. | Frog, Cat, Kitten, Tomcat and define | ||
49 | Anonymous Methods. We are sometimes | suitable constructors and methods | |
forced to create a class or a method just | according to the following rules: all of | ||
for the sake of using a delegate The code | this are Animals. Kittens and tomcats are | ||
involved is often relatively short and | cats. All animals are described by age, | ||
simple Anonymous methods let you define an | name and sex. Kittens can be only female | ||
nameless method called by a delegate Less | and tomcats can be only male. Each animal | ||
coding Improved code readability. | produce a sound. Create arrays of | ||
50 | Using Delegates: Standard Way. class | different kinds of animals and calculate | |
SomeClass { delegate void | the average age of each kind of animal | ||
SomeDelegate(string str); public void | using static methods. Create static method | ||
InvokeMethod() { SomeDelegate dlg = new | in the animal class that identifies the | ||
SomeDelegate(SomeMethod); | animal by its sound. 91. | ||
dlg("Hello"); } void | 92 | ? ? Questions? ? Object-Oriented | |
SomeMethod(string str) { | Programming with C#. ? | ||
Object-Oriented Programming with C#.pptx |
«Complex object в английском языке» - А вот как на практике реализуется complex object в английском языке: Как было видно из последних четырех пунктов, во всех случаях инфинитив употребляется с частицей to. Что представляет собой Complex Object в английском языке? В основном, сложное дополнение в английском языке используется после некоторых глаголов, которые можно сгруппировать в определенные категории.
«Перевод Complex Object» - Основные различия семантики инфинитива и ing-формы в Complex Object. Ко мне приближался какой-то слепой, но я вовремя заметил его. Свертка до номинализации (разной степени). Я увидел, что ко мне приблизился какой-то слепой. Far away he heard her sobbing (Woolf) - Далеко-далеко он слышал ее плач (Вульф).
«Complex object в английском языке» - А вот как на практике реализуется complex object в английском языке: Выражающими побуждение, принуждение: (to let – позволять, to make – заставлять, to have – распорядиться, to cause – причинять, заставлять). We saw the postman slip a thick envelope into the box. – Мы видели, как почтальон опустил в почтовый ящик толстый конверт.
«Написание письма на английском» - Как написать письмо. Оформление. Открытка. Личное письмо. План первой половины. Прочитайте отрывок из письма. Восклицательный знак. Отрывок из письма. Правила и советы. Варианты подписи. Задание. Наличие орфографических или грамматических ошибок. Варианты обращения. Почтовая открытка. Стратегии написания открытки.
«Деловое письмо на английском» - Четырьмя строчками ниже ставится ФИО и должность, а в полученном промежутке – подпись. В ответ на такое письмо отправляется письмо ответ. Форматирование абзацев – без использования отступа первой строки. Но поставщик должен обеспечивать дружеские, поддерживающие отношения и в начале переписки, и в дальнейшем.
«Грамматика английского языка» - Грамматика английского языка. Grammar and Vocabulary for First Certificate. Question tags. Determiners. Link words or phrases: purpose and reason. Present Continuous, be going to, Present Simple. Phrases of agreement Conditionals. Essential Grammar in Use Elementary. Future Continuous and Future Perfect.