TAILIEUCHUNG - C# 2005 Programmer’s Reference - Chapter 21

Tham khảo tài liệu 'c# 2005 programmer’s reference - chapter 21', công nghệ thông tin, kỹ thuật lập trình phục vụ nhu cầu học tập, nghiên cứu và làm việc hiệu quả | Chapter 21 The two GetEnumerator methods both acquire and return an available enumerator object. The enumerator object is initialized with the argument values and instance value saved when the enumerable object was initialized. The following example shows the GetEnumerator method in action. Here the method will return either an enumerator or an enumerable class for an ordered list of items. The order is preserved using a yield statement public lEnumerable GetEnumerator for int x 0 x x yield return itemArray x This next example uses a yield break to indicate that the last item has been yielded public IEnumerable GetShortEnumerator int l for int x 0 x x yield return itemArray x if x l yield break Summary In this chapter you examined iterators in C and how they can be used to return an ordered sequence of values. You looked in some detail at how the yield return and yield break statements offer flexibility in coding and how the four states of the enumerator objects provide great flexibility when coding. In Chapter 22 you examine safe and unsafe code. 264 99 Unsafe Code If you ve come from a C background you might have noticed one feature of C that has so far been absent in C pointers. In C the majority of memory management tasks that a C programmer would need to worry about are taken care of automatically. The thorough garbage collection in C and the .NET Framework along with the extensive use of references means that the C programmer can write powerful code yet remain totally oblivious to memory management. However there are times when it would be useful to have direct access to the memory in order to be able to write code that is more powerful and versatile than regular code. This kind of code is known as unsafe code. What is Unsafe Code While it is true that every pointer type construct found in C or C for that matter has a comparable reference type in C there are times when direct access to a pointer type is either useful or .

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.