TAILIEUCHUNG - Visual studio 2010 part 8

Loại A là một thuật ngữ chung cho các lớp, các module, sự đếm, và nhiều hơn nữa. Chương này cụ thể sẽ thảo luận về các loại lớp học, cho phép bạn tạo ra các loại riêng của bạn. Bạn cũng sẽ thấy giá trị của một lớp khi bạn học viên đến lớp học. Bạn sẽ thấy cách lĩnh vực, phương pháp, và các thành viên lớp tài sản có thể được sử dụng. Chúng tôi sẽ bắt đầu với việc học cách tạo và sử dụng các lớp học | Chapter 3 Learning Just Enough C and Types and Members 67 68 Microsoft Visual Studio 2010 A Beginner s Guide Key Skills Concepts Create Classes Write Methods Code Fields and Properties A type is a general term for classes modules enums and more. This chapter will specifically discuss the class type which allows you to create your own custom types. You ll also see the value of a class when you learn about class members. You ll see how the field method and property class members can be used. We ll start with learning how to create and use classes. Creating Classes Previously you learned about the primitive types which are built into languages and alias the underlying .NET types. You can also create your own types via classes which you can instantiate and create objects with. The following section explains how to create a class and then instantiate an object from it. Class Syntax To create a new custom class definition right-click the project select Add Class name the class Employee for this example and type the file extension .cs for C or .vb for VB then click Add VS will add this file extension for you if you don t . You ll see a file with the same code as Listing 3-1. Listing 3-1 A new Employee class C using System using using using namespace FirstProgram Chapter 3 Learning Just Enough C and Types and Members 69 public class Employee public string FirstName VB Public Class Employee Public Dim FirstName As String End Class The C Employee class is nearly the same as the Program class that you created in the preceding chapter except that the class name here is Employee. In VB you ve only created a module before and the Employee class is your first class for this book. You can add members to a class which could be events fields methods and properties. Listing 3-1 shows an example of a field FirstName and you ll learn about events methods and properties in later sections of this chapter. A field is a .

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.