TAILIEUCHUNG - Lesson 11: Indexers

This lesson teaches C# Indexers. | Tutorial Page 1 of 6 Using Excellent Tools to Write Web Applications Tar the .NET Common Language Runtime CLR Home Up Lesson01 Lesson02 Lesson03 Lesson04 Les Lesson06 Lesson07 Lesson08 Lesson09 Lesson10 Les Lesson12 Lesson13 On sale Now C Unleashed is an indepth guide for intermediate to advanced software developers to learn the C programming language and serve as a desktop reference. The C Station Tutorial by Joe Mayo 04 23 01 Lesson 11 Indexers This lesson teaches C Indexers. Our objectives are as follows Understand What Indexers Are For. Implement an Indexer. Overload Indexers. Understand How to Implement Multi-Parameter Indexers. Indexers are real easy. They allow your class to be used just like an array. On the inside of a class you manage a collection of values any wa you want. These objects could be a finite set of class members another array or some complex data structure. Regardless of the internal implementation of the class its data can be obtained consistently throug the use of indexers. Here s an example. Listing 11-1. An Example of An Indexer using System III summary III A simple indexer example. III Isummary class IntIndexer private string myData public IntIndexer int size myData new string size for int i 0 i size i myData i empty http Tutorials 6 24 2002 Tutorial Page 2 of 6 public string this int pos get return myData pos set myData pos value static void Main string args int size 10 IntIndexer myInd new Intlndexer size mylnd 9 Some Value myInd 3 Another Value myInd 5 Any Value nIndexer Output n for int i 0 i size i myInd 0 1 i myInd i Listing 11-1 shows how to implement an Indexer. The IntIndexer class ha a string array named myData. This is a private array that external users can t see. this array is initialized in the constructor which accepts an ini size parameter instantiates the myData array and then fills each elemei with the word empty . The next class .

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.