TAILIEUCHUNG - Remember Interfacing Working

Declaring Interface Properties You met interfaces in Chapter 12, “Working with Inheritance.” Interfaces can also specify properties. To do this, you declare the get or set keyword, or both, but replace the body of the get or set accessor with a semicolon. | Declaring Interface Properties You met interfaces in Chapter 12 Working with Inheritance. Interfaces can also specify properties. To do this you declare the get or set keyword or both but replace the body of the get or set accessor with a semicolon. For example interface IScreenPosition int X get set int Y get set Any class or struct that implements this interface must implement the accessors. For example struct ScreenPosition IScreenPosition . public int X get . set . public int Y get . set . . If you implement the interface properties in a class you can declare the property implementations as virtual which allows further derived classes to override the implementations. For example class ScreenPosition IScreenPosition . public virtual int X get . set . public virtual int Y get . set . . NOTE The example shows a class. Remember that the virtual keyword is not valid in structs because you can t derive from structs structs are implicitly sealed. You can also choose to implement a property by using the explicit interface implementation syntax covered in Chapter 12. An explicit implementation of a property is non-public and non-virtual and cannot be overridden . For example struct ScreenPosition IScreenPosition int get . set . int get . set . . private int x y Using Properties in a Windows Application When you use the Properties window in Microsoft Visual Studio 2005 you are actually generating code that sets and retrieves the values of properties of various application components items such as TextBox controls Forms and Button controls. Some components have a large number of properties although some properties are more commonly used than others. You can modify many of these properties at runtime by using the same syntax you have seen throughout this chapter. In the following exercise you will use some predefined properties of the TextBox controls and the Form class to create a simple application that continually displays the size of

TAILIEUCHUNG - Chia sẻ tài liệu không giới hạn
Địa chỉ : 444 Hoang Hoa Tham, Hanoi, Viet Nam
Website : tailieuchung.com
Email : tailieuchung20@gmail.com
Tailieuchung.com là thư viện tài liệu trực tuyến, nơi chia sẽ trao đổi hàng triệu tài liệu như luận văn đồ án, sách, giáo trình, đề thi.
Chúng tôi không chịu trách nhiệm liên quan đến các vấn đề bản quyền nội dung tài liệu được thành viên tự nguyện đăng tải lên, nếu phát hiện thấy tài liệu xấu hoặc tài liệu có bản quyền xin hãy email cho chúng tôi.
Đã phát hiện trình chặn quảng cáo AdBlock
Trang web này phụ thuộc vào doanh thu từ số lần hiển thị quảng cáo để tồn tại. Vui lòng tắt trình chặn quảng cáo của bạn hoặc tạm dừng tính năng chặn quảng cáo cho trang web này.