Chapter 8 Quick Reference

Chương 8 Quick tham khảo để làm điều này Đơn giản chỉ cần làm cho bản sao. Bởi vì biến là một loại giá trị, bạn sẽ có hai bản sao của cùng một giá trị. Ví dụ: Sao chép một giá trị biến kiểu int i = 42; int copyi = i; Đơn giản chỉ cần làm cho bản sao. | Chapter 8 Quick Reference To Do this Simply make the copy. Because the variable is a value type you will Copy a value type variable have two copies of the same value. For example int i 42 int copyi i Simply make the copy. Because the variable is a reference type you Copy a reference type variable will have two references to the same object. For example Circle c new Circle 42 Circle refc c Prefix the argument with the ref keyword. This makes the parameter an alias for the actual argument rather than a copy of the argument. For example Pass an argument to a ref parameter static void Main int arg 42 DoWork ref arg arg Prefix the argument with the out keyword. This makes the parameter an alias for the actual argument rather than a copy of the argument. For example Pass an argument static void Main to an out parameter Box a value int arg 42 DoWork out arg arg Initialize or assign a variable of type object to the value. For example Unbox a value object o 42 Cast the object reference that refers to the boxed value to the type of the value. For example int i int o

Bấm vào đây để xem trước nội dung
TÀI LIỆU MỚI ĐĂNG
7    74    2    17-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.