TAILIEUCHUNG - C#Your visual blueprint for building .NET applications phần 4

Bạn có thể tạo được xây dựng trong công đoàn thuộc tính trong C # vì vậy tất cả các lĩnh vực trong chương trình của bạn bắt đầu tại cùng một điểm trong bộ nhớ. LOẠI NÀY: sử dụng StructLayout (] / / Đặt thuộc tính cấu trúc trước khi tuyên bố cấu trúc struct Liên minh. | PROGRAMMING C BUILDING BLOCKS 4 You can create a built-in union attribute in C so that all fields in your program start at the same point in memory. TYPE THIS using StructLayout Place the struct attribute before declaring the struct. struct Union RESULT Declaring your struct information and the namespace ensures that you can run your program. After you declare your struct you can enter the struct constructor. L Type the output line for the End coordinates. Run the program by pressing the F5 key. The string appears on the screen. u Save the program as the filename. 83 C DISPLAY HEAP AND STACK INFORMATION C allocates memory in one of two ways heap and stack. The heap method provides more flexibility so classes usually use the heap method. The stack approach sets aside memory for processing. Structs use stack memory allocation because they are self-contained and know exactly how much memory to allocate for their operation. A heap memory method is a term that describes the dynamic allocation and freeing of objects as the program runs. The heap method is best when you do not know the amount of objects ahead of time and or the number of objects cannot fit into a stack. Because classes produce a large number of objects that cannot be known ahead of time the compiler allocates new classes and operators on the heap. A stack is an area of memory that holds arguments and variables. When the compiler compiles your project it automatically sets aside the stack memory it will need so your program will run properly. Because structs are self- contained the compiler knows how much memory to use and sets aside the stack. The heap method gives you more flexibility and it is best when you use classes. However you should use structs whenever possible to ensure that the amount of memory your project takes up is as low as possible which means your project is reaching peak performance. DISPLAY HEAP AND STACK .

TỪ KHÓA LIÊN QUAN
Đã 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.