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.
Співпраця з нами на GitHub
Джерело цього вмісту можна знайти на GitHub, де також можна створювати й переглядати запитання та запити на внесення змін. Докладні відомості наведено в нашому посібнику для співавторів.
Зворотний зв’язок
https://aka.ms/ContentUserFeedback.
Очікується незабаром: протягом 2024 року ми будемо припиняти використання механізму реєстрації проблем у GitHub для зворотного зв’язку щодо вмісту й замінювати його новою системою зворотного зв’язку. Докладніше:Надіслати й переглянути відгук про