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.
Samarbeid med oss på GitHub
Du finner kilden for dette innholdet på GitHub. Der du også kan opprette og se gjennom problemer og pull-forespørsler. Hvis du vil ha mer informasjon, kan du se vår bidragsyterveiledning.
Tilbakemeldinger
https://aka.ms/ContentUserFeedback.
Kommer snart: Gjennom 2024 faser vi ut GitHub Issues som tilbakemeldingsmekanisme for innhold, og erstatter det med et nytt system for tilbakemeldinger. Hvis du vil ha mer informasjon, kan du se:Send inn og vis tilbakemelding for