Teach Yourself the C# Language in 21 Days phần 6

Bạn không thể khai báo một xây dựng cho một cấu trúc mà không có tham số. Ví dụ 7,4 bao gồm các điểm Như bạn có thể nhìn thấy đầu ra, khi Dòng 22 được thực thi, sự kiện Change_D không còn hoạt động nữa. Tuy nhiên, xử lý sự kiện Change_A tiếp tục làm việc. | 380 Day 10 Enter the contractor s name Matt Hebron Enter c for Contractor e for Employee then press ENTER Z Contractor Amber Jones Employee Bejamin Andrews Employee Jacob Sams Contractor Matt Hebron Person Not an Employee or Contractor Analysis This is a long listing compared to what you have been seeing. This listing only partially implements everything it could do. One of today s exercises will have you expand on this listing. The purpose of the listing is to enable you to enter people into the program. This is set up to take five people however you could have the user enter people until a set value is entered. The program prompts you to enter either an e or a c to indicate whether the person is an employee or a contractor. Based on what you enter it gives you a custom prompt to enter the person s name. You could also ask for additional information however this hasn t been done here. If the user enters a value other than an e or c the program fills the person s name with an error message. You most likely would want different logic than this. You should also notice that although the program prompts for lowercase e or c uppercase letters also work. Most of the code should be familiar to you. The classes defined in this listing have been scaled back to a minimum amount of code. Lines 26 and 45 were left in the listing as comments. You will be asked to use these data members in one of today s exercises. In Line 63 you see the beginning of the Main method for this application. Lines 69-102 contain a that loops for each person being entered. Lines 71-75 contain a nested which prompts the user to enter either an e or a c to indicate the type of person being entered. Using a ReadLine in Line 74 the user s answer is obtained. Users who press Enter are prompted again. When a value is entered statements are used to determine what processing should occur. In Line 77 only the first character of the text entered by the user is reviewed. The first .

Không thể tạo bản xem trước, hãy bấm tải xuống
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.