Apress Introducing Dot Net 4 With Visual Studio_1

Tham khảo tài liệu 'apress introducing dot net 4 with visual studio_1', công nghệ thông tin, hệ điều hành phục vụ nhu cầu học tập, nghiên cứu và làm việc hiệu quả | CHAPTER 4 CLASSES STRUCTS AND OBJECTS You do not know the compiler-generated name of the type therefore you are forced to declare the variable instance as an implicitly typed local variable using the var keyword as I did in the code. Also notice that the compiler-generated type is a generic type that takes two type parameters. It would be inefficient for the compiler to generate a new type for every anonymous type that contains two types with the same field names. The output above indicates that the actual type of employeeinfo looks similar to the type name below fAnonymousType0 And because the anonymous type for customerinfo contains the same number of fields with the same names the generated generic type is reused and the type of customerinfo looks similar to the type below fAnonymousType0 Had the anonymous type for customerinfo contained different field names than those for employeeinfo then another generic anonymous type would have been declared. Now that you know the basics about anonymous types I want to show you an abbreviated syntax for declaring them. Pay attention to the bold statements in the following example using System public class ConventionalEmployeeinfo ._ public ConventionalEmployeeinfo string Name int Id Name Id public string Name get return name set name value public int Id get return id set id value private string name private int id public class EntryPoint 89 CHAPTER 4 CLASSES STRUCTS AND OBJECTS static void Main ConventionalEmployeeInfo oldEmployee new ConventionalEmployeeInfo Joe 42 var employeeinfo new string Name Jane int id 1234 var customerinfo new Name Id employeeInfo Name 0 Id 1 customerInfo Name 0 Id 1 Anonymous Type is actually 0 For illustration purposes I have declared a type named

Không thể tạo bản xem trước, hãy bấm tải xuống
TỪ KHÓA LIÊN QUAN
TÀI LIỆU MỚI ĐĂNG
576    116    7    26-05-2024
Đã 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.