TAILIEUCHUNG - Lesson 7: Introduction to Classes

This lesson introduces you to C# Classes. | Tutorial Page 1 of 4 Using Excellent Tools to Write Web Applications Tar the .NET Common Language Runtime CLR Home Up LessonOI Lesson02 Lesson03 Lesson04 Les Lesson06 Lesson07 Lesson08 Lesson09 LessonlO Les Lesson12 Lesson13 On sale Now C Unleashed is an indepth guide for intermediate to advanced software developers to learn the C programming language and serve as a desktop reference. The C Station Tutorial by Joe Mayo 10 29 00 11 13 01 Lesson 7 Introduction to Classes This lesson introduces you to C Classes. Our objectives are as follows Implement Constructors. Know the difference between instance and static members. Using Destructors. Familiarization with Class Members. Since the beginning of this tutorial you have been using classes. By now you should have a sense of what a class is for and how to specify one. Th lesson will build upon what you already know and introduce the various class members. Classes are declared by using the keyword class followed by the class name and a set of class members surrounded by curly braces. Every class has a constructor which is called automatically any time an instance of a class is created. The purpose of constructors is to initialize class membe when the class is created. Constructors do not have return values and always have the same name as the class. Listing 7-1 is an example of a class. Listing 7-1. Example C Classes Namespace Declaration using System helper class class OutputClass string myString Constructor public OutputClass string inputstring http Tutorials 6 24 2002 Tutorial Page 2 of 4 myString inputstring Instance Method public void printString 0 myString Destructor OutputClass Some resource cleanup routines Program start class class ExampleClass Main begins program execution. public static void Main Instance of OutputClass OutputClass outCl new OutputClass This is printed by the output class. Call Output class method Listing 7-1 .

TỪ KHÓA LIÊN QUAN
TÀI LIỆU MỚI ĐĂNG
Đã 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.