What is the Difference between ref and out keyword?
will you brief describe about ref and out keywords
Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
Lakshmanan Sethu SankaranarayanRank #124 · 17.7K reputationPosted Apr 30, 2014, 11:53 PM EDT
Pawan KumarRank #8,839 · 215 reputationPosted Apr 30, 2014, 11:11 PM EDT
In C Sharp, Parameters are passed by value to a method by default. If we want to pass them by reference then we can use either "out" or "ref" keyword.
Output parameters: In this the variable specified at the time of calling does not need to have a assigned value. When method is invoked completely, we can read that variable.
Reference Parameter: In this, we don't pass the value of the parameter instead we pass the address of the variable. No new storage is created for this. it manipulate the same storage address Reference parameters require ref modifier as part of both the declaration and the calling.
best of luck !!!!