tailieunhanh - Visual studio 2010 part 6

Microsoft Visual Studio 2010: A của Hướng dẫn mới bắt đầu mà bạn sẽ thấy nhiều lần trong suốt cuốn sách này. Các ứng dụng điều khiển được xác định mã bộ xương lớp để có chương trình tên. Trong thực tế bạn có thể đặt tên cho bất cứ điều gì lớp bạn muốn. Dù tên bạn chọn nên có ý nghĩa cho mục đích của lớp. Ví dụ, nó có ý nghĩa cho một lớp học mà các công trình với khách hàng để được đặt tên là Khách hàng và chỉ có các phương pháp giúp bạn làm. | 42 Microsoft Visual Studio 2010 A Beginner s Guide which you ll see many times throughout this book. The Console application defined the skeleton code class to have the name Program. In reality you can name the class anything you want. Whatever names you choose should make sense for the purpose of the class. For example it makes sense for a class that works with customers to be named Customer and only contain methods that help you work with customers. You wouldn t add methods for working directly with invoices products or anything other than customers because that would make the code in your Customer class confusing. Classes are organized with namespaces which are discussed next. The FirstProgram Namespace A namespace helps make your class names unique and therefore unambiguous. They are like adding a middle name and surname to your first name which makes your whole name more unique. A namespace name however precedes the class name whereas your middle name and surname follow your first or given name. A namespace also helps you organize code and helps you find things in other programmers code. This organization helps to build libraries of code where programmers have a better chance to find what they need. The .NET platform has a huge class library that is organized into namespaces and assemblies this will become clearer the more you program. The main .NET namespace is System which has multiple sub-namespaces. For example guess where you can find .NET classes for working with data Look in . Another quick test Where are .NET classes for working with networking protocols like TCP IP FTP or HTTP Try . Another benefit of namespaces is to differentiate between classes that have the same name in different libraries. For example what if you bought a third-party library that has a Customer class Think about what you would do to tell the difference between Customer classes. The solution is namespaces because if each Customer has its own namespace you can