Добавил:
Upload Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:
C# 2008 Step by Step.pdf
Скачиваний:
26
Добавлен:
25.03.2016
Размер:
13.96 Mб
Скачать

Chapter 21 Operator Overloading

411

8.Close the application, and return to the Visual Studio 2008 programming environment.

If you want to continue to the next chapter:

Keep Visual Studio 2008 running, and turn to Chapter 22. If you want to exit Visual Studio 2008 now:

On the File menu, click Exit. If you see a Save dialog box, click Yes (if you are using Visual Studio 2008) or Save (if you are using Visual C# 2008 Express Edition) and save the project.

Chapter 21 Quick Reference

To

Do this

Implement an operator

Write the keywords public and static, followed by the return type,

 

followed by the operator keyword, followed by the operator symbol

 

being declared, followed by the appropriate parameters between

 

parentheses. For example:

 

struct Hour

 

{

 

...

 

public static bool operator==(Hour lhs, Hour rhs)

 

{

 

...

 

}

 

...

 

}

 

 

Declare a conversion

Write the keywords public and static, followed by the keyword implicit

operator

or explicit, followed by the operator keyword, followed by the type be-

 

ing converted to, followed by the type being converted from as a single

 

parameter between parentheses. For example:

 

struct Hour

 

{

 

...

 

public static implicit operator Hour(int arg)

 

{

 

...

 

}

 

...

 

}

Microsoft Visual C# 2008 Step by Step

Part IV

Working with Windows

Applications

In this part:

Chapter 22. Introducing Windows Presentation Foundation . . . . . . . . . . . . . . . . 415 Chapter 23. Working with Menus and Dialog Boxes . . . . . . . . . . . . . . . . . . . . . . . 451 Chapter 24. Performing Validation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 473

413

Соседние файлы в предмете [НЕСОРТИРОВАННОЕ]