TAILIEUCHUNG - aspnet sample_part7

Các lớp học Hình . Một lớp phục vụ như là các kế hoạch chi tiết cho một đối tượng. Chúng tôi thấy rằng Rayne là một đối tượng của lớp Dog. Trong đoạn mã của chúng tôi, chúng tôi có thể tạo ra một thể hiện mới của lớp Dog, gọi nó Rayne, và sử dụng tất cả các thuộc tính và phương pháp tiếp xúc với đối tượng. | Classes Figure . A class serves as the blueprint for an object. Base Class Object Rayne Create Instance Properties Color Eye Color Height Length Weight Methods Sit Lay Down Shake Come Property values Color Gray White and Black Eye Color Blue and Brown Height 18 Inches Length 36 Inches Weight 30 Pounds Methods Sit Lay Down Shake Come We see that Rayne is an object of class Dog. In our code we could create a new instance of the Dog class call it rayne and use all the properties and methods exposed by the object. In OOP when we create new instances of a class we say we re instantiating that class. For instance no pun intended if we need to programmatically create a new instance of the Button control class we could write the following code Dim myButton As New Button C Button myButton new Button As you can see we ve essentially created a new object called myButton from the Button class. We can then access the properties and methods that the Button exposes through our new instance Click Me C Click Me Order the prin T er is -hiis trial version 77 Chapter 3 and C Programming Basics Scope You should now have a concept of programming objects as entities that exist in a program and are manipulated through the methods and properties they expose. However in some cases we want to create methods to use inside our class which are not available when that class is used in code. Let s return to the Dog class to illustrate. Imagine we re writing the Sit method inside this class and we realize that before the dog can sit it has to shuffle its back paws forward a little Just bear with me on this one. We could create a method called ShufflePaws then call that method from inside the Sit method. However we don t want code in an page or in some other class to call this method it d just be silly. We can prevent this by controlling the scope of that method. The two types of scope available in and C that you .

TỪ KHÓA LIÊN QUAN
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.