ref (C# reference)
You use the ref
keyword in the following contexts:
- In a method signature and in a method call, to pass an argument to a method by reference.
- In a method signature, to return a value to the caller by reference. For more information, see
ref return
. - In a declaration of a local variable, to declare a reference variable.
- As the part of a conditional ref expression or a ref assignment operator.
- In a
struct
declaration, to declare aref struct
. For more information, see theref
structure types article. - In a
ref struct
definition, to declare aref
field. For more information, see theref
fields section of theref
structure types article.
Cộng tác với chúng tôi trên GitHub
Bạn có thể tìm thấy nguồn cho nội dung này trên GitHub, nơi bạn cũng có thể tạo và xem lại các vấn đề và yêu cầu kéo. Để biết thêm thông tin, hãy xem hướng dẫn dành cho người đóng góp của chúng tôi.
Phản hồi
https://aka.ms/ContentUserFeedback.
Sắp ra mắt: Trong năm 2024, chúng tôi sẽ dần gỡ bỏ Sự cố với GitHub dưới dạng cơ chế phản hồi cho nội dung và thay thế bằng hệ thống phản hồi mới. Để biết thêm thông tin, hãy xem:Gửi và xem ý kiến phản hồi dành cho