Danh mục

The System.Object Class

Số trang: 1      Loại file: pdf      Dung lượng: 7.75 KB      Lượt xem: 1      Lượt tải: 0    
Thu Hiền

Xem trước 1 trang đầu tiên của tài liệu này:

Thông tin tài liệu:

Các System.Object Class Một trong những loại tài liệu tham khảo quan trọng nhất trong NET Framework. Là lớp Object trong namespace System. Để đánh giá đầy đủ ý nghĩa của lớp System.Object yêu cầu bạn hiểu thừa kế
Nội dung trích xuất từ tài liệu:
The System.Object Class The System.Object ClassOne of the most important reference types in the .NET Framework is the Object class inthe System namespace. To fully appreciate the significance of the System.Object classrequires that you understand inheritance, which is described in Chapter 12, “Workingwith Inheritance.” For the time being, simply accept that all classes are specialized typesof System.Object, and that you can use System.Object to create a variable that can referto any reference type. System.Object is such an important class that C# provides theobject keyword as an alias for System.Object. In your code, you can use object or youcan write System.Object; they mean exactly the same thing.TIPUse the object keyword in preference to System.Object. Its more direct and its alsoconsistent with using other keywords that have longer synonyms, as youll discover inChapter 9, “Creating Value Types with Enumerations and Structs.” If your programcontains a using System; directive, you could also write Object with a capital O (withoutthe System. prefix), but its best to consistently use the simpler keyword object.In the following example, the variables c and o both refer to the same Circle object. Thefact that the type of c is Circle and the type of o is object (the alias for System.Object) ineffect provides two different views of the same object:Circle c;c = new Circle(42);object o; o = c;

Tài liệu được xem nhiều: