TAILIEUCHUNG - Professional C# Third Edition phần 2

phân hủy các quan điểm nonrefreshable vật chất, và bản sửa lỗi cho các vấn đề vật chất nhật ký. Nó cũng cho bạn biết làm thế nào để làm cho một cái nhìn vật chất đủ điều kiện cho một làm mới nhanh chóng, nếu nó không phải là. bắt đầu DBMS | Chapter 3 -----Simpo PDF Merge and Split Unregistered Version - http value for each instance of a class. This means that unlike a const field if you want a readonly field to be static you have to declare it as such. Suppose we have an MDI program that edits documents but that for licensing reasons we want to restrict the number of documents that can be opened simultaneously. Now assume that we are selling different versions of the software and it s possible that customers can upgrade their licenses to open more documents simultaneously. Clearly this means we can t hard-code the maximum number in the source code. We d probably need a field to represent this maximum number. This field will have to be read in perhaps from a registry key or some other file storage each time the program is launched. So our code might look something like this public class DocumentEditor public static readonly uint MaxDocuments static DocumentEditor MaxDocuments DoSomethingToFindOutMaxNumber In this case the field is static since the maximum number of documents only needs to be stored once per running instance of the program. This is why it is initialized in the static constructor. If we had an instance readonly field then we would initialize it in the instance constructor s . For example presumably each document we edit has a creation date which you wouldn t want to allow the user to change because that would be rewriting the past . Note that the field is also public we don t normally need to make readonly fields private because by definition they cannot be modified externally the same principle also applies to constants . As noted earlier date is represented by the class . In the following code we use a constructor that takes three parameters the year month and day of the month you can find details of this and other DateTime constructors in the MSDN documentation public class Document public readonly DateTime CreationDate public Document .

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.