1. Trang chủ
  2. » Công Nghệ Thông Tin

Chapter 14 Quick Reference

2 271 0
Tài liệu đã được kiểm tra trùng lặp

Đang tải... (xem toàn văn)

THÔNG TIN TÀI LIỆU

Thông tin cơ bản

Tiêu đề Chapter 14 Quick Reference
Định dạng
Số trang 2
Dung lượng 7,3 KB

Các công cụ chuyển đổi và chỉnh sửa cho tài liệu này

Nội dung

Chapter 14 Quick Reference Declare a read/write property for a struct or class.. Declare the type of the property, its name, a get accessor, and a set accessor.. For example: struct Scre

Trang 1

Chapter 14 Quick Reference

Declare a read/write

property for a struct or

class

Declare the type of the property, its name, a get accessor, and a set accessor For example:

struct ScreenPosition {

public int X {

get { } set { } }

}

Declare a read-only

property for a struct or

class

Declare a property with only a get accessor For example:

struct ScreenPosition {

public int X {

get { } }

}

Declare a write-only

property for a struct or

class

Declare a property with only a set accessor For example:

struct ScreenPosition {

public int X {

set { } }

} Declare a property in an

interface

Declare a property with just the get or set keyword, or both For example:

Trang 2

To Do this

interface IScreenPosition {

int X { get; set; } // no body int Y { get; set; } // no body }

Implement an interface

property in a struct or

class

In the class or struct that implements the interface, declare the property and implement the accessors For example:

struct ScreenPosition : IScreenPosition {

public int X {

get { } set { } }

public int Y {

get { } set { } }

}

Ngày đăng: 07/11/2013, 17:15

TỪ KHÓA LIÊN QUAN